How to sort integer list in python descending order -


i have tried figure out in different ways, no success. keep getting ascending order sort, rather descending order when print.

listb = [24, 13, -15, -36, 8, 22, 48, 25, 46, -9] sorted(listb, key=int, reverse=true) print sorted(listb) 

you printing list sorted ascending:

print sorted(listb) 

if want descending, put print statement on previous line (where reverse it)

print sorted(listb, key=int, reverse=true) 

then remove final print statement.

example:

>>> listb = [24, 13, -15, -36, 8, 22, 48, 25, 46, -9] >>> print sorted(listb, key=int, reverse=true) [48, 46, 25, 24, 22, 13, 8, -9, -15, -36] 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -