Reputation: 23
I have the following list
distances = ['5.67', '8.91', '6.48', '9.32', '13.38', '14.99']
I have did some research and have tried
sorted(distances , key = float)
and I have also tried
distances.sort()
However neither have worked. Wondering what i am doing wrong?
Upvotes: 1
Views: 3543
Reputation: 366
Your approach should work. How do you want the values sorted?
distances = ['5.67', '8.91', '6.48', '9.32', '13.38', '14.99']
distances = sorted(distances, key=float)
print(distances)
['5.67', '6.48', '8.91', '9.32', '13.38', '14.99']
Upvotes: 1