I need to sort a list of strings which contains digits at the beginning and end of the string, first by the beginning digits, then by the ending digits. So the beginning digits have priority over the ending digits.
For example:
l = ['900abc5', '3000abc10', '1000abc5', '1000abc10', '900abc20']
Would become:
l = ['900abc5', '900abc20','1000abc5','1000abc10','3000abc10']
I know that l.sort() will not work here as it sorts lexicographically. Any other methods I tried seemed to be excessively complicated (example: splitting the strings by matching beginning digits, then splitting again by ending digits, sorting, concatenating, and then recombining the list) Even summarizing that method shows that it is not efficient!
Edit: after playing around with the natsort module I found that natsorted(l) solves my particular issue.