How to sort a list of numeric strings in descending order with Python

1 Answer

0 votes
lst = ["7", "0", "55", "8", "9", "6"]
  
lst.sort(key = int, reverse=True)
 
for i in range(len(lst)) :
    print(lst[i], end=" ")
     
     
 
'''
run:
 
55 9 8 7 6 0 

'''

 



answered Sep 3, 2022 by avibootz
...