GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Sort Multi Dimension array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Sort Multi Dimension array" Watch "Sort Multi Dimension array" New topic
Author

Sort Multi Dimension array

sudhir pavan
Ranch Hand

Joined: Sep 01, 2011
Posts: 34
How to sort array list with multi dimension value in java using built in function.

Ex:

No Name Address

5 sss US
1 www UK
4 yyyy SL
Emanuel Kadziela
Ranch Hand

Joined: Mar 24, 2005
Posts: 186
Create a class representing the objects with the given attributes, something like this:



Create/populate the List with these objects:



Create the comparator for these objects:


Invoke the sort utility:
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39093
    
  23
Your post is a little confusing. Do you mean to sort an array or a List? Does the List contain objects of your class? I would say the only object‑oriented way to do it is to create objects of some class or other. Then, as an alternative to the Comparator, you can make that object implement the Comparable interface. You can find more about the interfaces mentioned in the Java Tutorials.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Sort Multi Dimension array