1 | initial version |
you've been using min() and max() there, in a similar way, you can just sort your list of rectangles by size:
rects = [[1,2,3,4],[5,6,7,8],[4,3,2,1]] r2 = sorted(rects, key=lambda r: r[2]*r[3]) r2 [[4, 3, 2, 1], [1, 2, 3, 4], [5, 6, 7, 8]]
2 | No.2 Revision |
you've been using min() and max() there, in a similar way, you can just sort your list of rectangles by size:
>>>
rects = [[1,2,3,4],[5,6,7,8],[4,3,2,1]]