Python tutorials: Sorting (reverse, key, multiple attributes / value)

preview_player
Показать описание
#LetslearnPython
#sort python list
#Python advanced sorting
#Python sort key

In this video we will discuss some of the more advanced features of sorting in Python.
You can reverse sort in Python using argument "reverse".
Python also allows sorting by lambda function, by utilizing it's key function.
We will also learn about sorting by multiple attributes in Python, which is something I just recently learned about.

You can find the notebook here in my Python stuff repository:

Рекомендации по теме
Комментарии
Автор

Hi... If we need order the first item of the tuple in ascending order and the second in descending order? Is it possible with sorted?

leonardorezende
Автор

OMG u r a saviour, i have been banging my head to actually get this, you made it so simple, thnks a ton

bubblebath
Автор

Wasted a lot of time trying to get this and you explained it in less than 6 minutes.

thePronto
Автор

i like you include both pronunciation of tuple whenever you say it.

tsunningwah
Автор

glist=sorted(glist, key=lambda x:abs(x), reverse=True)

ProphetPearls
Автор

Which is it, a tuple or a tuple?? ;)
Thanks for the content!

Ausare
Автор

you are the best u just saved me with the multiple attributes idea!! THANKS MANN (subscribed + liked)

azk
Автор

Last one wont work for me i need to sort participants from highest to lowest but if there are lik 56 and 56 i need to put it lexicographically and when i get to 100 it puts that participant as lowest

damirdamnjanovic
Автор

Wtf I just spent 30 min trying to figure this ish out.

englishlit
Автор

How do I manage to have the key and the value in a list beneath each other making just 1 list??


Thanks

waterdamagerestoration
Автор

What are tuples-tooples? Can't find anything about them in the python documentation.

onlinecomedyclub
Автор

Its bad practice to assign a lambda function to a variable. They are supposed to be anonymous and used in-line.

gedtoon