sophryu99/TIL

Sorting 2d array by the first or the second element

Opened this issue · 0 comments

>>> intervals = [[2,6],[8,10],[15,18],[1,3]]
intervals.sort(key=lambda pair: pair[0])

>>> intervals = [[1,3],[2,6],[8,10],[15,18]]