Использование numpy:
# Width Meters
data = np.array([[[144, 500], # Group 1
[142, 450]],
[[140, 500], # Group 2
[156, 460]]])
# Pick the group with the largest sum of Meters
group_index = np.argmax(data.sum(1)[:,1])
print(f'Group with the largest sum of Meters: Group {group_index + 1}')
result = data[group_index]
# sort by Width in descending order
result = result[np.argsort(result[:,0])[::-1]]
Результат:
array([[156, 460],
[140, 500]])
РЕДАКТИРОВАТЬ:
data = np.array([[[144, 500],
[142, 450],
[150, 300]],
[[140, 500],
[156, 460],
[145, 300]],
[[170, 500],
[180, 455],
[160, 300]]])
# Sort Groups by the sum of Meters
group_inds = np.argsort(data.sum(1)[:, 1])[::-1]
result = data[group_inds]
# Sort by Width in each group
result = result[np.arange(data.shape[0])[:, None],
np.argsort(result[..., 0], axis=1)[:,::-1]]
Результат:
array([[[156, 460],
[145, 300],
[140, 500]],
[[180, 455],
[170, 500],
[160, 300]],
[[150, 300],
[144, 500],
[142, 450]]])