I have this simple program that is supposed to sort the array of arrays by the key.
Why is the sorted()
function saying that it only takes 1 argument, and that I am not providing any?
import operator
array = [[1, 6, 3], [4, 5, 6]]
sorted_array = sorted(iterable=array, key=operator.itemgetter(array[0][1]), reverse=True)
print(sorted_array)
And the error this gives:
Traceback (most recent call last):
File "...", line 4, in <module>
sorted_array = sorted(iterable=array, key=operator.itemgetter(array[0][1]), reverse=True)
TypeError: sorted expected 1 argument, got 0