I have a list in this format:
exon_start exon_finish gene_name (repeated hundreds of times)
I want to sort by exon_start
Example list:
['8342758', '8344137', 'NM_001042682']
['85420368', '85421471', 'NM_032184']
['86363115', '86364485', 'NM_152890']
['89820771', '89822936', 'NM_015350']
['904123', '905900', 'NR_027693']
['91176416', '91179454', 'NM_201269']
['92418409', '92420740', 'NM_015237']
['93575521', '93577419', 'NR_034089']
['94114411', '94116006', 'NM_014597']
['99926918', '99928016', 'NM_017734']
This list of lists (printed above) has already been sorted with the following code:
sorted_triplets = sorted(triplets, key=lambda x: x[0])
for i in sorted_triplets:
print i
However, "sorted" isn't working like I expect. As you can see from the list, 904123 is less than 89820771. So it appears that "sorted" isn't comparing the numbers as a whole, rather as individual digits.
How do I fix this?