-6

how to sort object in array list that contains :

ID   Name    price
1    aa      123
2    bb      100
3    cc      100
4    dd      300
5    ee      100

with price low to high

Nadim Baraky
  • 459
  • 5
  • 18
  • 1
    I didn'y downvote you, but you should really consider doing that sort in the database as it was designed to sort quickly. What would be a one line query in SQL could take several dozen lines of Java code, and it would be slower than the database. – Tim Biegeleisen May 31 '16 at 10:44
  • data above not from database. so I can't use query to sort it. – Franky Kuyz May 31 '16 at 10:49
  • 2
    @FrankyKuyz your question title states something different. But based on your comment your question is probably duplicate of [Sort ArrayList of custom Objects by property](http://stackoverflow.com/questions/2784514/sort-arraylist-of-custom-objects-by-property) – Pshemo May 31 '16 at 11:08
  • For me, it was clear and I was going to post an answer! – Nadim Baraky May 31 '16 at 16:50

1 Answers1

3

Why don't you use:

SELECT * FROM your_table ORDER BY PRICE ASC
apomene
  • 14,282
  • 9
  • 46
  • 72
ugali soft
  • 2,719
  • 28
  • 25