Interesting question! I did a little digging around and playing around and yes you can. You can use nested sorting as follows (I wish I could have included it in my video): func = lambda x: (x[0]) func2 = lambda x: (x[1]) sorted(sorted(tuple_list, key = func), key = func2, reverse = True) You can stack the sort!
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
@@PyMoondra I know how to get the output of the value, and the key seperately. But my question is, how I get them under each other.... like the value under the key (or the other way around) ?? Like in this case I want to have the a,b,c, etc first (the whole alphabet). And then the Alpha, beta, etc. under all the letters. www.screencast.com/t/h1kXtHzkUKX
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?
Interesting question! I did a little digging around and playing around and yes you can. You can use nested sorting as follows (I wish I could have included it in my video):
func = lambda x: (x[0])
func2 = lambda x: (x[1])
sorted(sorted(tuple_list, key = func), key = func2, reverse = True)
You can stack the sort!
key = lambda x : (x[0], -x[1])
PyMoondra don’t do this
@@momshadalvee brilliant, thank you.
@@momshadalvee what if you want to sort x[0] in the reverse order? because you cannot use -x[0] for string
OMG u r a saviour , i have been banging my head to actually get this , you made it so simple , thnks a ton
Wasted a lot of time trying to get this and you explained it in less than 6 minutes.
i like you include both pronunciation of tuple whenever you say it.
Exactly what I was looking for.
Welcome to my channel too, which has both Python and R playlists, ppt and coding windows, with downoadabe source files.
Thanks, Great demonstration!
Tuples Tooples :) Nice explanation.
He should have just picked one way to say it and gone with it.
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
glist=sorted(glist,key=lambda x:abs(x),reverse=True)
awesome bruh!! love from india 😍
you are the best u just saved me with the multiple attributes idea!! THANKS MANN (subscribed + liked)
Thank you some much for the support.
@@PyMoondra i'm wondering if you can do a video about function complexity with big O and stuff?
Which is it, a tuple or a tuple?? ;)
Thanks for the content!
What are tuples-tooples? Can't find anything about them in the python documentation.
tuples. Type of data contained/data structure in Python
@@PyMoondra not tuples. Tuples-tooples.
@@onlinecomedyclub5725 there's not such thing
@@onlinecomedyclub5725 the joke somehow flew over both of their heads
How do I manage to have the key and the value in a list beneath each other making just 1 list??
Thanks
I am not quite sure exactly what you mean.
@@PyMoondra I know how to get the output of the value, and the key seperately. But my question is, how I get them under each other.... like the value under the key (or the other way around) ?? Like in this case I want to have the a,b,c, etc first (the whole alphabet). And then the Alpha, beta, etc. under all the letters. www.screencast.com/t/h1kXtHzkUKX
Thanks a lot, very useful video
Thank you for such a nice comment!
Wtf I just spent 30 min trying to figure this ish out.
what is it key = len
Its bad practice to assign a lambda function to a variable. They are supposed to be anonymous and used in-line.
mafhemt chay ...