python sort string of numbers code example
Example 1: sort strings as numbers python
a = sorted(a, key=lambda x: float(x))
Example 2: sort strings as numbers python
>>> b = ["949.0","1099.0"]
>>> b.sort(key=float)
>>> b
['949.0', '1099.0']
a = sorted(a, key=lambda x: float(x))
>>> b = ["949.0","1099.0"]
>>> b.sort(key=float)
>>> b
['949.0', '1099.0']