| Author |
ordering values in Arraylist
|
Sherif Shehab
Ranch Hand
Joined: Mar 05, 2007
Posts: 472
|
|
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: 3011
|
|
|
There are methods for sorting Lists in the Collections class
|
Joanne
|
 |
Sherif Shehab
Ranch Hand
Joined: Mar 05, 2007
Posts: 472
|
|
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: 19216
|
|
|
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
How To Ask Questions How To Answer Questions
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
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: 32712
|
|
|
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
|
|
|