sort a 2d matrix based on 2nd element code example Example: python order 2d array by secode element sorted(arr, key=lambda x: x[1])