I have a lista_tupla = [(1, [1, 2, 3, 4]), (2, [5, 6, 7]), (3, [7, 8, 9]), (3, [10, 11, 12]), (4, [13, 14, 15])]
where the first index of each tuple is a key and the second index is a list as above.
I would like to know: how do I sort it by the key? I tried the following command:
lista_tupla_ordenada = lista_tupla.sort(key=lambda, x: x[1])
But it did not work. Return:
>>> lista_tupla_ordenada = lista_tupla.sort(key=lambda, x: x[1])
File "<stdin>", line 1
lista_tupla_ordenada = lista_tupla.sort(key=lambda, x: x[1])
^
SyntaxError: invalid syntax
How can I resolve this?
PS: yes, I need every duplicate key in my tuple: P