File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes ordering values in Arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "ordering values in Arraylist" Watch "ordering values in Arraylist" New topic
Author

ordering values in Arraylist

Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 477

Hi Guys ,

i got an ArrayList contains these values

but the values are messed up , i wanna order them to be in this order


Any ideas to achieve this ?


Thanks,
Sherif
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
There are methods for sorting Lists in the Collections class


Joanne
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 477

Joanne Neal wrote:There are methods for sorting Lists in the Collections class


but this mentioned in the documentation
Sorts the specified list into ascending order, according to the natural ordering of its elements
so this will not make it in the order i need above ..
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19544
    
  16

Then check the other sort method, which takes a java.util.Comparator. Implement your own Comparator class that does the sorting for you.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
Sherif Shehab wrote:but this mentioned in the documentation
Sorts the specified list into ascending order, according to the natural ordering of its elements
so this will not make it in the order i need above ..


Note that I said there are methods for sorting. Try taking a look at the other one.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
That looks like a tree; maybe you should to work out how to associate a FinancialStatus object with a List<FinanceStatus>.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ordering values in Arraylist
 
Similar Threads
Removing multiple if conditions
Derby Embedded Database: errors in connection code
Many-to-many probelm help
Unable to understand the setAttribute in java
Initializing and adding to an ArrayList