1

I have a list of tuples like this:

data = [('ab15', 'abc'), ('ab4', 'abc'), ('ab12', 'abc'), ('ab7', 'abc')]

An I want to sort by the first element of the subset, to have:

[('ab4', 'abc'), ('ab7', 'abc'), ('ab10', 'abc'), ('ab12', 'abc')]

I tried to use sorted: sorted(data) But with this, I have:

[('ab10', 'abc'), ('ab12', 'abc'), ('ab4', 'abc'), ('ab7', 'abc')]

What is not what I wan't. Is there an easy way to do it ?

Thanks

Alain
  • 380
  • 1
  • 5
  • 15

0 Answers0