• Post Reply Bookmark Topic Watch Topic
  • New Topic

ordering values in Arraylist  RSS feed

 
Ranch Hand
Posts: 492
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 ?
 
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
 
S Shehab
Ranch Hand
Posts: 492
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 ..
 
Sheriff
Posts: 21201
87
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.
 
Marshal
Posts: 57238
175
  • 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
Boost this thread!