How to sort python list of strings of numbers

You want to sort based on the float values (not string values), so try:

>>> b = ["949.0","1099.0"]
>>> b.sort(key=float)
>>> b
['949.0', '1099.0']

Leave a Comment