I have a list
a = ['d2da1.png','d2da11.png','d2da2.png','d2da111.png','d2da22.png']
that I want to automatically sort based upon the last number before the period, .
in each element. This number in the string may be any integer of any length (e.g. 1
,11
,2
,111
,22
). The output sought is
a = ['d2da1.png','d2da2.png','d2da11.png','d2da22.png','d2da111.png']
Conventional methods such as sorted
fail here, and brute forcing may be time-intensive if considering very large lists. Therefore, is there a way to sort the strings above based upon the last full number in the string to output the sought list?