I have a list of ['rs12345','rs21','rs55189'];
I need to sort them as numbers after strip the prefix 'rs'.
How can I do it in Python ?
# row.keys() is ['rs12345','rs21','rs55189']
fieldnames = sorted(list(row.keys()),key=itemgetter(slice(2, None)))
This code will not working after add int(''.join(xxx)).
And the dict row is a generator so I have to put it into list() to get its values.
_fieldnames = list(row.keys())
_fieldnames.remove(sidname)
_fieldnames = sorted(_fieldnames, key=lambda i: int(i[2:]))
Got it working.
I forgot that I have to remove sampleid, which contains no ^rs,  first.
 
    