my dog learned polymorphism*
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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: 483

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: 3502
    
  14
There are methods for sorting Lists in the Collections class


Joanne
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

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: 19684
    
  20

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: 3502
    
  14
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: 38513
    
  23
That looks like a tree; maybe you should to work out how to associate a FinancialStatus object with a List<FinanceStatus>.
 
 
subject: ordering values in Arraylist