How to sort a list of strings of int numbers by numeric order in Python

1 Answer

0 votes
lst = ['123', '380', '75', '0', '50', '-1', '5' , '3']
  
lst.sort(key=int)
  
print(lst)
  
  
  
'''
run:
  
['-1', '0', '3', '5', '50', '75', '123', '380']
  
'''

 



answered Jan 21, 2020 by avibootz
edited Jan 22, 2020 by avibootz

Related questions

...