I have a list of strings that may contain digits. I would like to sort this list alphabetically, but every time the String contains a number, I want it to be sorted by value. For example, if the list is
['a1a','b1a','a10a','a5b','a2a'],
the sorted list should be
['a1a','a2a','a5b','a10a','b1a']
In general I want to treat each number (a sequence of digits) in the string as a special character, which is smaller than any letter and can be compared numerically to other numbers.
Is there any python function which does this compactly?
'ab1c'and'a1ef'?mylist.sort()method ?