Sort List Of Lists Of Lists Python
I have a List of Lists of Lists in python. I need to sort the highest level of lists based on one of the values in the lowest levels. For a toy model, my list is created first wit
Solution 1:
This can be done in one line:
sorted_large = sorted(large, key=lambda item: item[1][0][1])
The sorted
built-in function takes a key
parameter:
key
specifies a function of one argument that is used to extract a comparison key from each list element
Using a lambda
expression, the sorting key can be extracted.
Post a Comment for "Sort List Of Lists Of Lists Python"