[Tutor] How to sort float number from big numbers to small numbers?

Alan Gauld alan.gauld at yahoo.co.uk
Mon Sep 25 09:43:20 EDT 2017


On 25/09/17 04:34, edmundo pierre via Tutor wrote:
> I am trying to sort float numbers input by an user from the bigger to smaller number. I do not know how to compare float numbers. Any ideas? Thank you!

The same way you sort anything else.
Using the comparison operations
==, <, >, <=, >=

There is a slight snag in that comparing float to absolute values is not 
straightforward but for sorting thats irrelevant.

Of course, normally you just use the sort() method to do it, or call the 
sorted() function.


Alan G



More information about the Tutor mailing list