For example, consider the string '3a+1+4c+3b'
. Then, using some regex, you split that into ['3a','1','4c','3b']
. How could I rearrange that list so that it is sorted such that the number without a letter following is put first in the list, then the rest of the elements are sorted in the in increasing values of number/letter combinations? For example, ['3a','1','4c','3b']
becomes ['1','3a','3b','4c']
.
Edit:
So, just to clarify, I did use sorted
, but if I use it, for example, on 2k+1-6j+9i
, which turns into ['1', '2k', '6j', '9i']
, as you can seem it is not sorted in order of increasing letter value. I want it to instead be ['1','9i','6j','3k']
.