A seemingly simple problem, but one that's proving a bit vexing. I have a list of chromosomes (there are 23 chromosome - chromosomes 1 to 21, then chromosome X and chromosome Y) like so:
['chr11','chr14','chr16','chr13','chr4','chr13','chr2','chr1','chr2','chr3','chr14','chrX',]
I would like to sort this in the following order :
['chr1', 'chr2','chr2','chr3','chr4','chr11','chr13','chr13', 'chr14','chr14','chr16','chrX']
However, due to the lexicographical nature of python's sort it will sort chr1, chr10, chr11, chr12...chr2, etc. as I have chromosome X, sorting by their integer values also doesn't seem like an option. would I potentially have to specify a unique key by which to sort the list? Or is there some sort of obvious solution I'm missing.