static public List < Rectangle > sortBySize ( List < Rectangle > list ) { List < Rectangle > result = Lists . newArrayList ( ) ; Collections . sort ( list , new Comparator < Rectangle > ( ) { @ Override public int compare ( Rectangle r1 , Rectangle r2 ) { return ( r1 . height * r1 . width ) - ( r2 . height * r2 . width ) ; } } ) ; return result ; }
sort a list of rectangles by their sizes in ascending order