Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ordering values in Arraylist

 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are methods for sorting Lists in the Collections class
 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then check the other sort method, which takes a java.util.Comparator. Implement your own Comparator class that does the sorting for you.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48430
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks like a tree; maybe you should to work out how to associate a FinancialStatus object with a List<FinanceStatus>.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic