Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > sorting method for 2D Object array?

Reply
Thread Tools

sorting method for 2D Object array?

 
 
Jeff
Guest
Posts: n/a
 
      12-18-2004
I need a sorting method for a 2 dimensional object array. Does anyone know
of a publicly available one?

Thanks

--
Jeff


 
Reply With Quote
 
 
 
 
Starshine Moonbeam
Guest
Posts: n/a
 
      12-18-2004
In article <nHKwd.779$EL5.573@trndny09>, Jeff
((E-Mail Removed)) 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][b]) {

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









 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting list vs sorting vector boltar2003@boltar.world C++ 2 07-06-2010 09:40 AM
Dumb question: in documentation, why Object#method, and not Object.method ? Elf M. Sternberg Ruby 15 07-29-2009 01:20 AM
fired event Sorting which wasn't handled - sorting and SelectedIndexChanged Jason ASP .Net Web Controls 0 10-04-2006 02:19 PM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
sorting by multiple criterias (sub-sorting) Tom Kirchner Perl Misc 3 10-11-2003 05:16 PM



Advertisments