python - Sorting a list with entries in string format -
in python, have list items (strings) this:
"1.120e+03 8.140e+02 3.234e+01 1.450e+00 1.623e+01 7.940e+02 3.113e+01 1.580e+00 1.463e+01"
i want sort list based on size of first number in each string (smallest largest). in above case "1.120e+03"
.
i can think of couple of ways it, involve creating new lists , couple of loops guess isn't efficient (or elegant). there quick way this?
if sorting more once, suggest create class data , override methods comparing such __lt__
.
Comments
Post a Comment