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 Sort Multi Dimension array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
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: 39478
    
  28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sort Multi Dimension array