With this code, I get sorted list based on the length of element.
>>> a = [[1,2,3],[3,4,5,6],[7,8],[9,10,11]]
>>> print sorted(a, key=lambda m: len(m))
[[7, 8], [1, 2, 3], [9, 10, 11], [3, 4, 5, 6]]
When sorting the list of list, I need to introduce some randomness when the length of the element is the same. For the previous example. I need to get sorted results
[[7, 8], [1, 2, 3], [9, 10, 11], [3, 4, 5, 6]]
or
[[7, 8], [9, 10, 11], [1, 2, 3], [3, 4, 5, 6]]
in random.
How can I make that in Python?
[[8, 7], [4, 3, 6, 5], [11, 9, 10], [1, 2, 3]]2:[[7, 8], [3, 4, 5, 6], [9, 10, 11], [1, 2, 3]]