File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Formating a String-Array with more than one dimension Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Formating a String-Array with more than one dimension" Watch "Formating a String-Array with more than one dimension" New topic
Author

Formating a String-Array with more than one dimension

Ben Klug
Ranch Hand

Joined: Jan 28, 2002
Posts: 45
Hello,
how can i sort this array 'o' by the first colmn??
//********************************
String o[][] = new String[3][2];
o[0][0]="1111111111";
o[0][1]="eins";
o[1][0]="0000000000";
o[1][1]="zwei";
o[2][0]="2222222222";
o[2][1]="drei";
for (int i = 0; i < o.length ; i++){
System.out.println(o[i][0] + "||" + o[i][1]);
}
//********************************
thanks in advance
Ben
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
The easiest way is to create a java.util.Comparator which compares the first entries in two String[] arrays. Then use java.util.Arrays.sort(Object[], Comparator) to sort the array quickly, with minimal fuss. This may a bit advanced for the "Beginner" forum, but it's worth the effort to learn how Comparators work.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Formating a String-Array with more than one dimension