No video

Python Tutorials - Sorted Function | How to Sort List Tuple and Dictionaries

  Рет қаралды 61,847

Amulya's Academy

6 жыл бұрын

In this Python programming video tutorial we will learn how to sort list tuple dictionaries using sorted function in detail.
Sorted is builtin function can be used to sort iterables, which will return a new list with sorted elements.
Syntax of sorted function is:
sorted(iterables, key = None , reverse = false)
Here in this tutorial we will discuss about key function and reverse in detail with example.
For more free tutorials on computer programming
AmulsAcademy
AmulsAcademy

Пікірлер: 96
@helloworld2458
@helloworld2458 4 жыл бұрын
which data structures can the key be used in? we can do the same in lists too right? Thanks for tips
@redmi9power879
@redmi9power879 Жыл бұрын
Thank you ma'am I was frustrated from the key function but clear all my douts related to key function
@ikamesh1390
@ikamesh1390 4 жыл бұрын
Hi Can we use sorted() for nested dictionaries? for ex cars = {"bmw":{"model":"rv10","Gear":"Auto","Year":2016},"Benz":{"model":"rv20","year":2019},'Audi':{"model":"rf30", "year":2019}} We can only use sorted() on keys. What if we want to do it for values and items?
@willingtushar
@willingtushar 5 жыл бұрын
Which mic do you use?
@zico07
@zico07 5 жыл бұрын
Liked your videos a lot. Videos are very helpful for beginners.
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Thank you:)
@vipin_mishra19
@vipin_mishra19 5 жыл бұрын
Your voice is amazing and explanation also best
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Thank you:)
@YEON_09
@YEON_09 3 жыл бұрын
Flirt yaha pe bhi😜😂
@irvanalhaq7324
@irvanalhaq7324 9 ай бұрын
Great explanation
@deepak_kori
@deepak_kori Жыл бұрын
your videos are best
@atifshaik9329
@atifshaik9329 6 жыл бұрын
can you help with Memory Game programs and remote server using python
@Entertainment_world_A1468
@Entertainment_world_A1468 8 ай бұрын
Mam for dict can't we use def method instead of lambda
@steephansteephan1360
@steephansteephan1360 11 ай бұрын
Thank you very much mam, very useful
@somayehmadadpour8833
@somayehmadadpour8833 4 жыл бұрын
Hello dear. Why defining function to manipulate items does not work for dictionary? Because we used it for tuple and list but not dictionary and instead you used lambda.
@JohnOdunayo
@JohnOdunayo Жыл бұрын
Thanks a lot helped me with understanding an expression in cs50
@easydatascience2508
@easydatascience2508 Жыл бұрын
Hei, you can watch my playlists for Python and R too, thank you.
@helloworld2458
@helloworld2458 4 жыл бұрын
thanks python is cool you can sort any data structure based on the index
@huehuehue13
@huehuehue13 3 жыл бұрын
THANKYOU SM FOR THIS! GREAT VIDEO!!!
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you 😊❤️
@logeshk2811
@logeshk2811 5 жыл бұрын
Super explanation.
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Thank you :)
@bhupindersingh-kf2mo
@bhupindersingh-kf2mo 2 жыл бұрын
thank you making this video
@-BMadhan
@-BMadhan 4 жыл бұрын
Your explanation and voice is good to understand
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@diwalibreakdancer7819
@diwalibreakdancer7819 Ай бұрын
Hello pls help what is we only want to sort value of index 2:5 and print the rest as it is
@amiddleclassboy410
@amiddleclassboy410 3 жыл бұрын
Explanation and voice both are awsm mam...like u r teaching to small kids...really awsm
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you :)
@BaziJo
@BaziJo 5 жыл бұрын
thank you for you nice video
@Viralvlogvideos
@Viralvlogvideos 4 жыл бұрын
can u explain how key=lambda x:x[1] is working
@vinodch8056
@vinodch8056 6 жыл бұрын
Waiting for some more videos and plz speak abut small project that will help lot of members
@AmulsAcademy
@AmulsAcademy 6 жыл бұрын
Sure:)
@samrasoli
@samrasoli Жыл бұрын
useful, thanks
@karthikspartan281
@karthikspartan281 2 жыл бұрын
Excellent
@santosh_ksh7
@santosh_ksh7 2 жыл бұрын
Thanks 👍
@sameersyed6770
@sameersyed6770 2 жыл бұрын
Python program to get a list, sorted in increasing order by the last element in each tuple from a given list of non-empty tuples.. can anyone explain me in detail?
@shubhendrasingh8376
@shubhendrasingh8376 4 жыл бұрын
Awesome explanation..
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@babyfox205
@babyfox205 4 жыл бұрын
haha good job, I liked your explanations. Thank you for these tutorials!
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Pleasure :)
@dhanamillionaire8936
@dhanamillionaire8936 3 жыл бұрын
Awesome explanation ☺️
@9336611680
@9336611680 5 жыл бұрын
well explained...thanks
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Thank you:)
@darlolo1916
@darlolo1916 5 жыл бұрын
why you ding it in shell, and how can you print it???
@deepshikhakhatri3338
@deepshikhakhatri3338 3 жыл бұрын
Really helpful video.....❤️
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Glad to hear that :)
@77Sherms
@77Sherms 3 жыл бұрын
In reference to the key function, how does it know to skip the item at the next index so it sorts based on the letter? I.e. 'a' is at index [1] (which you put in the return statement) and then it sorts based on every item at every second index. So its sorting based on items at indexes [1] [3] [5 ][7] or does the indexing for each nested tuple start again? So the index number for each letter in the nested tuple is [1]? Also, I note that when you call the function in the sorted method you do not use parentheses at the end of the function I.e. normally when you call a function you put Secondvlaue(). Why is the parentheses at the end of the function not required when using it in the sorted function? Thanks. Good video btw.
@77Sherms
@77Sherms 3 жыл бұрын
Additional: I played around with indexing nested tuples and discovered that if you want to access a single item in a nested tuple you have to specify the index of the nested tuple and the index of the item in the nested tuple. I.e. [0][0] will retrurn item 1 from (1, 'a').
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Hey if i take nested list like this: list1 = [[1,2],[3,4]] if i want to access 1 then i need to take list1[0][0] because in list1 [1,2] list index is 0 [3,4] list index is 1. in the inner lists, list [1,2] index of 1 is 0 and 2 is 1. and also in list [3,4] index of 3 is 0 and 4 is 1. functions are called without parenthesis because parenthesis are added to key function inside the code written for sorted function. :)
@77Sherms
@77Sherms 3 жыл бұрын
@@AmulsAcademy thanks. I still don't understand how the secondVlaue() function knows to call the second item in the first, and subsequent, nested tuples with the use of only one index. To call second item in the nested tuple, shouldn't it be [0] [1]?
@PoojaYadav-fu6oy
@PoojaYadav-fu6oy 3 жыл бұрын
Ma'am you are awesome thankyou ma'am 😘💖
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Most welcome 😊
@eshwarvecham3647
@eshwarvecham3647 4 жыл бұрын
Mam, the function secondvalue is accepting one argument but when we are calling the function i.e used in key we are not passing any argument. Can u clarify my doubt.
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
It will take iterable(the first value in the sorted(), list,dictionary,tuple) as argument to the function.
@eshwarvecham3647
@eshwarvecham3647 4 жыл бұрын
Ok mam thnks for ur reply. The function will be applied on each element of iterable? The secondvalue function is called as many times as the elements in iterable?
@blatogh1277
@blatogh1277 4 жыл бұрын
it is so clear OMG
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@kushaldas8496
@kushaldas8496 4 жыл бұрын
Mam at 5.30 I can't understand here how lambda function works? Can you please explain me please mam 🙏
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
it will return the first element of the dictionary item.
@Viralvlogvideos
@Viralvlogvideos 4 жыл бұрын
AWESOME TUTORIAL BRUH, whats is ur age ??
@homataha5626
@homataha5626 2 жыл бұрын
what if we wanted to sort the tuple by the second element?
@samrasoli
@samrasoli Жыл бұрын
items2 = [ (10, "product1"), (23, "product3"), (4, "product2") ] print(items2) items2.sort(key=lambda x:x[1]) print(items2)
@alexandergarzo9415
@alexandergarzo9415 Жыл бұрын
I like your voice!
@venkatkrishnan9777
@venkatkrishnan9777 2 жыл бұрын
Tq
@OldOne.OO1
@OldOne.OO1 3 жыл бұрын
مبدعه👍
@madushani6844
@madushani6844 3 жыл бұрын
How to write a code to get the ascending order of this kind of list 21R12014 21R22007 21R12100 21R32055 i must consider only last three numbers when sort these list with ignoring first five characters😒 Can u help me? ❤️
@blatogh1277
@blatogh1277 4 жыл бұрын
Actually, nice
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@rishisharma5249
@rishisharma5249 6 жыл бұрын
Mam will you teach Numpy, pandas, Matplotlib,scikit learn etc.. in the future videos😁
@AmulsAcademy
@AmulsAcademy 6 жыл бұрын
Sure:)
@rishisharma5249
@rishisharma5249 6 жыл бұрын
Thanks mam
@SanathKumarBennurAsh
@SanathKumarBennurAsh 8 ай бұрын
​@@AmulsAcademypls reply if u have done videos on the above mentioned by @rishisharma Thank you
@liri1189
@liri1189 2 жыл бұрын
Dictionaries are now ordered
@tanmoysardar3908
@tanmoysardar3908 6 жыл бұрын
maam have u done with that turtle graphics part
@AmulsAcademy
@AmulsAcademy 6 жыл бұрын
No:(
@tanmoysardar3908
@tanmoysardar3908 6 жыл бұрын
Amuls Academy mam then will u post plz maam its urgent coding samajna hain mereko
@charancharan2417
@charancharan2417 6 жыл бұрын
If I post any queries in python then will you respond with answer
@AmulsAcademy
@AmulsAcademy 6 жыл бұрын
yes:)
@AmulsAcademy
@AmulsAcademy 6 жыл бұрын
yes:)
@kurakulaprashanth4302
@kurakulaprashanth4302 5 жыл бұрын
How did you called that second value function without using parathesis like "**we should call like this na second value() ***""" Please reply mam. Waiting for your reply.
@kurakulaprashanth4302
@kurakulaprashanth4302 5 жыл бұрын
@@AmulsAcademy you didn't passed the arguments to the function but you got the output how?
@ThatControlUser
@ThatControlUser 3 жыл бұрын
@@kurakulaprashanth4302 kwargs :/
@innocentsahir908
@innocentsahir908 6 жыл бұрын
i have queries on python can u help me
@AmulsAcademy
@AmulsAcademy 6 жыл бұрын
Sure:)
@innocentsahir908
@innocentsahir908 6 жыл бұрын
Hi Thanks for reply let me share my queries over email. can i know your Id regards
@AmulsAcademy
@AmulsAcademy 6 жыл бұрын
amulsacademy@gmail.com
@atifshaik1518
@atifshaik1518 6 жыл бұрын
Thanks
@atifshaik1518
@atifshaik1518 6 жыл бұрын
waiting to your reply pls contact me asap thanks
@ashu60071
@ashu60071 4 жыл бұрын
How to sort without inbuilt functions
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
You can use sorting algorithms. Bubble sort Merge sort ..... :)
@ashu60071
@ashu60071 4 жыл бұрын
Amuls Academy sure I will try. Could you please make us understand array manipulation problem like 5 3 1 3 100 2 4 100 3 5 100 Such that output should be 100 200 200 200 100
@kushagraverma7400
@kushagraverma7400 2 жыл бұрын
this guy is chintu from whitehat jr
Wait for the last one! 👀
00:28
Josh Horton
Рет қаралды 136 МЛН
ОДИН ДЕНЬ ИЗ ДЕТСТВА❤️ #shorts
00:59
BATEK_OFFICIAL
Рет қаралды 8 МЛН
Wait for the last one! 👀
00:28
Josh Horton
Рет қаралды 136 МЛН