File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sort Multi Dimension array

 
sudhir pavan
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47274
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic