How do I temporarily sort a list alphabetically in reverse?

222 views Asked by At

Like to use reverse sort in command its: variable.sort(reverse=True) but this is permanent.

The sorted command is only temporary such as: print(sorted(variable)) so how do I make that one in reverse?

2

There are 2 answers

0
Will Gosnold On

Simple one :)

sorted(your_list, reverse=True)

0
Sparkling Marcel On
sorted(variable,  reverse=True)

Use the keyword argument reverse inside the sorted function, and put it to True for it to be reversed

that should do exactly what you want