The working solution is below !
First try:
>>> l = ['SRATT', 'SRATW', 'CRAT', 'CRA0', 'SRBTT', 'SRBTW', 'SRAT0', 'SRBT0']
>>> sorted(l, key=lambda x: (x[:-1], x[-1].isdigit()))
['CRAT', 'CRA0', 'SRATT', 'SRATW', 'SRAT0', 'SRBTT', 'SRBTW', 'SRBT0']
UPDATE
@StefanPochmann , .
,
>>> l = ['SRATT', 'SRATW', 'CRAT', 'CRA0', 'SRBTT', 'SRBTW', 'SRAT0', 'SRBT0', 'B', 'A']
>>> sorted(l, key=lambda x: (x[:-1], x[-1].isdigit(), x))
^
additional element
['A', 'B', 'CRAT', 'CRA0', 'SRATT', 'SRATW', 'SRAT0', 'SRBTT', 'SRBTW', 'SRBT0']
(, )
@Demosthene , , true
, ( ) , , . '{'
:
sorted(l, key=lambda x: ''.join((x[:-1], '{')) if x[-1].isdigit() else x)
sorted(l, key=lambda x: x[:-1] + '{' if x[-1].isdigit() else x)
@StefanPochmann. , .