Skip to main content
deleted 376 characters in body
Source Link
baz
  • 1.5k
  • 19
  • 12

There is a operator < between lists e.g.:

[12, 'tall', 'blue', 1] < [4, 'tall', 'blue', 13]

will give

False

So you need to arrange list elements by the desired order:

ls = [[12,  'tall', 'blue',  1],
      [ 2, 'short',  'red',  9], 
      [ 4,  'tall', 'blue', 13],
      [12, 'short',  'red',  0]]
ls.sort()
print(*ls, sep='\n')

will give:

[2, 'short', 'red', 9]
[4, 'tall', 'blue', 13]
[12, 'short', 'red', 0]
[12, 'tall', 'blue', 1]

There is a operator < between lists e.g.:

[12, 'tall', 'blue', 1] < [4, 'tall', 'blue', 13]

will give

False

So you need to arrange list elements by the desired order:

ls = [[12,  'tall', 'blue',  1],
      [ 2, 'short',  'red',  9], 
      [ 4,  'tall', 'blue', 13],
      [12, 'short',  'red',  0]]
ls.sort()
print(*ls, sep='\n')

will give:

[2, 'short', 'red', 9]
[4, 'tall', 'blue', 13]
[12, 'short', 'red', 0]
[12, 'tall', 'blue', 1]

There is a operator < between lists e.g.:

[12, 'tall', 'blue', 1] < [4, 'tall', 'blue', 13]

will give

False
Source Link
baz
  • 1.5k
  • 19
  • 12

There is a operator < between lists e.g.:

[12, 'tall', 'blue', 1] < [4, 'tall', 'blue', 13]

will give

False

So you need to arrange list elements by the desired order:

ls = [[12,  'tall', 'blue',  1],
      [ 2, 'short',  'red',  9], 
      [ 4,  'tall', 'blue', 13],
      [12, 'short',  'red',  0]]
ls.sort()
print(*ls, sep='\n')

will give:

[2, 'short', 'red', 9]
[4, 'tall', 'blue', 13]
[12, 'short', 'red', 0]
[12, 'tall', 'blue', 1]