我需要按照特定的元素对数组进行排序。
This is an array:arr=
[0, [71, 554, 258, 793]]
[1, [61, 415, 148, 593]]
[2, [91, 145, 658, 893]]
I need to be able to sort it by arr[0][0] as well as by any element from the internal array like arr[0][1] or arr[0][2]
currently, I'm able to sort it by using key=itemgetter(1) where: itemgetter(1) - is second element of array [0, [71, 554, 258, 793]] in this cese = 71from operator import itemgetter
array = sorted(array, key=itemgetter(1))
print(*array[:], sep="\n")
how to sort this array by any element from the internal array [71, 554, 258, 793]?
so if I'm sorting by the second element from internal array output should be like this: (column 145, 415, 554)arr=
[2, [91, 145, 658, 893]]
[1, [61, 415, 148, 593]]
[0, [71, 554, 258, 793]]
如果我从内部数组输出按第三个元素进行排序,应该如下所示:(第148、258、658列)arr=
[1, [61, 415, 148, 593]]
[0, [71, 554, 258, 793]]
[2, [91, 145, 658, 893]]