java - Sort arraylist of objects by one of their properties (double value) -
this question has answer here:
i'm attempting sort arraylist
of bountyobject
s property .getamount()
returns double
..
i've looked @ similar question on here , it's not pointing me in right direction, explain how sort this:
list<bountyobject> sortedlist = new arraylist<bountyobject>(); (bountyobject bo : bounties) // bounties original list of unsorted objects { // sort them sorted list bo.getamount() - highest lowest value }
any appreciated, thank you
using collections, can
collections.sort(bounties, new comparator<bountyobject>() { @override public int compare(bountyobject bo1, bountyobject bo2) { return (bo1.getamount() > bo2.getamount() ? 1:-1); }
Comments
Post a Comment