sorting method for 2D Object array?

Discussion in 'Java' started by Jeff, Dec 18, 2004.

  1. Jeff

    Jeff Guest

    I need a sorting method for a 2 dimensional object array. Does anyone know
    of a publicly available one?

    Thanks

    --
    Jeff
     
    Jeff, Dec 18, 2004
    #1
    1. Advertising

  2. In article <nHKwd.779$EL5.573@trndny09>, Jeff
    () dropped a +5 bundle of words...

    > I need a sorting method for a 2 dimensional object array. Does anyone know
    > of a publicly available one?


    You could make your own with nested for loops. (1 for the first
    dimension, which is really an array, and 1 for the array being held in
    the slot.

    <sscce>

    public class Test {

    int [][] thing = { {1,2,3},
    {4,5,6},
    {7,8,9} };


    public void findNumber() {

    int number = 5;

    for (int a = 0; a < 3; a++) {
    for (int b = 0; b < 3; b++){

    if (number == thing[a]) {

    System.out.println("\n" + number);

    } else {

    System.out.print("\nCouldn't find it.");

    } // end if/else

    } //end inside for loop
    } // end outside for loop

    } // end findNumber

    public static void main(String[] args) {

    Test drive = new Test();
    drive.findNumber();

    }
    }

    </sscce>


    --
    Starshine Moonbeam
    mhm31x9 Smeeter#29 WSD#30
    sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM
     
    Starshine Moonbeam, Dec 18, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    9
    Views:
    592
    justanotherguy
    Dec 3, 2004
  2. markspace
    Replies:
    1
    Views:
    407
    markspace
    Jun 25, 2009
  3. Richard Lionheart
    Replies:
    27
    Views:
    439
    Jean-Hugues ROBERT
    May 4, 2004
  4. Elf M. Sternberg
    Replies:
    15
    Views:
    282
    Matthias Reitinger
    Jul 29, 2009
  5. Joe User
    Replies:
    11
    Views:
    193
    Josh Cheek
    Dec 29, 2009
Loading...

Share This Page