In Python, is there a way to sort a list of lists and tuples, sequentially?
view a
and b
for me as expected, then why c
is it different? Is there a way to make it compatible with a
and b
without converting everything to a list or tuples?
>>> a = [(1, 0), (0, 0)]
>>> a.sort()
>>> print a
[(0, 0), (1, 0)]
>>>
>>> b = [[1], (0)]
>>> b.sort()
>>> print b
[0, [1]]
>>>
>>> c = [[1, 0], (0, 0)]
>>> c.sort()
>>> print c
[[1, 0], (0, 0)]
>>>
+3
source to share
2 answers