I have a list like this;
List = [('apple 5', 12), ('apple 3', 2), ('apple 6', 10),('apple 4', 15), ('apple 9', 11), ('apple 7', 14), ('apple 18', 10), ('apple 16', 10),('orange 5', 4), ('orange 4', 7)]
I know how to sort the list normally.
for i in sorted(List):
print(i)
this gives;
('apple 16', 10)
('apple 18', 10)
('apple 3', 2)
('apple 4', 15)
('apple 5', 12)
('apple 6', 10)
('apple 7', 14)
('apple 9', 11)
('orange 4', 7)
('orange 5', 4)
But can I sort something like this?
('apple 3', 2)
('apple 4', 15)
('apple 5', 12)
('apple 6', 10)
('apple 7', 14)
('apple 9', 11)
('apple 16', 10)
('apple 18', 10)
('orange 4', 7)
('orange 5', 4)