java - Sort arraylist of objects by one of their properties (double value) -


i'm attempting sort arraylist of bountyobjects 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

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -