Python Tutorial: Sorting Lists, Tuples, and Objects

Поделиться
HTML-код
  • Опубликовано: 10 янв 2025

Комментарии •

  • @jameezybreezy9030
    @jameezybreezy9030 5 лет назад +211

    For those reading the comments: this channel is a goldmine!

    • @coreyms
      @coreyms  5 лет назад +11

      Thanks!

    • @upupaepops6700
      @upupaepops6700 4 года назад +7

      No, you are wrong, this channel is one DIAMONDMINE which is more worth then GOLDMINE 😁😁😁😁

    • @8koi139
      @8koi139 3 года назад

      Indeed!!

    • @kipronoelijahkoech4630
      @kipronoelijahkoech4630 3 года назад

      You are very right! Corey makes learning so easy!

    • @JJ-rz6km
      @JJ-rz6km 3 года назад

      cant agree more!

  • @galleryofdeb
    @galleryofdeb 6 лет назад +34

    I wonder how can someone dislike these tutorials

  • @mateuszsmendowski2677
    @mateuszsmendowski2677 5 лет назад +6

    Amazing. Thanks to you, I have learned so much when I discovered your channel. My grandpa had told me a long time ago: "Knowing how to do something
    is not valuable, but knowing how to do something and why to do this in such a way is.". You give us pure knowledge. Thank you.

  • @maahasgharali571
    @maahasgharali571 7 лет назад +13

    Hello Sir, THANK YOU SOO MUCH. i literally spend 3 hours to figure out how can i sort my complex tuple...and still didnt get it...Until i watch this video. Please keep up the great work. and thanks once again

  • @cutieFAIZANHASSAN
    @cutieFAIZANHASSAN 5 лет назад +3

    The ease with which this person writes the code is ultra classy. I can only wish I had the knowledge as superior as Corey's.

  • @TheFourOnSix
    @TheFourOnSix 8 лет назад +44

    Hey, thanks for the video! I just started learning Python in order to get into Data Science and Machine Learning. These have been by far the simplest and easiest videos for me to understand and apply. Thank you!

    • @sushichanel7299
      @sushichanel7299 6 лет назад +1

      Hi John , How is going with my machine learning. I am learning python for machine learning. Hope to hear your advise. Thanks.

    • @ruslanuchan8880
      @ruslanuchan8880 6 лет назад

      I'm also want to learn it, how did it go with you three people? xD

    • @aabhishek4911
      @aabhishek4911 6 лет назад

      How did it go for the 4 of you ?

    • @ruslanuchan8880
      @ruslanuchan8880 6 лет назад

      @@aabhishek4911 Haven't really started. I'm currently learning software engineering for my university focus path. I'm learning Python and SQL on the side though.

    • @DeepF-r5g
      @DeepF-r5g 5 лет назад

      How’s it goin for the 5 of you?

  • @david-krikheli
    @david-krikheli 6 лет назад +36

    Excellent video. Love it! The Employee class can be made sortable by defining the __lt__ method like
    def __lt__(self, other):
    return self.name < other.name

  • @yihongli350
    @yihongli350 2 года назад +1

    Your video is the best for Python learners !!!!!!!!

  • @eatbreathedatascience9593
    @eatbreathedatascience9593 3 года назад +1

    Corey is teaching the things we need to know exactly. Thanks.

  • @samwood3691
    @samwood3691 6 лет назад +1

    Loving the series and wanted to say thank you for putting this out. I noticed due to a typo in my hand typing/copying the code and running it that it is worth mentioning that like other languages I have looked at (which would be just barely getting into C and basic) that sorting strings is based upon the ASCII set, which means that sorting the words 'OS' and 'age' due to lowercase being higher numbered the 'age' string is returned after the 'OS' string. These videos are awesome, TY again for doing this

  • @ripperx444
    @ripperx444 6 лет назад +2

    Omg man these videos are beyond amazing. I know python but as i watch your tutorials I see how much extra bs I do that not needed!!!! I didn’t always thohhht that the function in key param should be a custom lambda...

  • @h.mafnannazir9481
    @h.mafnannazir9481 8 лет назад +18

    Excellent way teaching

  • @itsmohitkhudotiya
    @itsmohitkhudotiya 2 года назад

    you're incredible at explaining stuff man

  • @chemago9938
    @chemago9938 7 лет назад

    i was here coz i had a problem sorting objects . Job well done. Thanks. If you open a school, i will be the first to enroll

  • @heroponrikibestest9295
    @heroponrikibestest9295 7 лет назад

    Thank you. This helped so much. Now I can finish my clay shooter project and have a sorted list of names and high scores sorted by scores. Thank you very much!

  • @HopeMichaels
    @HopeMichaels 4 года назад +1

    nice place to go back to the basics and a great road for beginners

  • @dexterflodstrom9975
    @dexterflodstrom9975 4 года назад +1

    Who would have thought sorting things was so easy! Thanks man, this is gonna be useful =D

  • @almatnarmatov
    @almatnarmatov 4 года назад +1

    Good bless you
    and God bless your courses
    learning to get my goal to financially independent
    and work in space company and start-ups!

  • @8koi139
    @8koi139 3 года назад

    Omg I have learned so much about this basic topic even tho I'm working whit classes!!

  • @tineyperson
    @tineyperson Год назад

    the reason they removed the dislike button was because they did not want people to dislike this video because its so good

  • @onlinecomedyclub5725
    @onlinecomedyclub5725 3 года назад

    7:07
    clearest explanation of #repr

  • @mdwasim959
    @mdwasim959 3 года назад

    Thats awesome one..whenever I see some coding of you I also try to do my way..
    class Employee():
    def __init__(self,n,a,s):
    self.n=n
    self.a=a
    self.s=s
    def __repr__(self):
    return '({},{},${})'.format(self.n,self.a,self.s)
    e1=Employee('carl',45,7000)
    e2=Employee('sarah',35,2000)
    e3=Employee('john',25,1000)
    ee=[e1,e2,e3]
    l=[]
    for a in ee:
    l.append(a.s)
    print(sorted((l)))
    Thanks for your awsome tutorial.. :)

  • @jeremypynn5844
    @jeremypynn5844 4 года назад +21

    I like how every video that uses lambda always says 'im not gonna get into lambda'.

    • @louistannudin2486
      @louistannudin2486 4 года назад +1

      I feel like its not as hard as it seems? Maybe I am being ignorant

    • @m12652
      @m12652 3 года назад

      Don’t panic... take a look at anonymous functions in javascript, then come back to python, take a deep breath and relax :)

    • @fmailscammer
      @fmailscammer 3 года назад

      @@louistannudin2486 i agree, though sometimes i can't quite wrap my head around it and get confused

  • @davidalexander829
    @davidalexander829 6 лет назад +1

    Wow! A hellava lot more effort to do the same thing in Java for a Java newb. Employee class. Excellent example. This video identified an area that I need to focus on. The __ whatever__ functions

    • @coreyms
      @coreyms  6 лет назад +2

      I have a video on that double underscore functions. If you search my channel for “special methods” you will find them there

  • @intense0excellent
    @intense0excellent 7 лет назад

    @4:45
    3 lines of code to do what I've been struggling to do with 12-18 lines. Good work, sir.

  • @snpsforyomom
    @snpsforyomom 7 лет назад

    I was trying to do this exact thing just today. so glad I stumbled on this video. thanks!

  • @AABb-ch2ri
    @AABb-ch2ri 3 года назад +1

    For 8:01 what if I wanted to put input values for the name age and salary how will I do that?

  • @shvideo1
    @shvideo1 2 года назад +2

    Awesome video, so very well explained. Thank you for sharing.

    • @easydatascience2508
      @easydatascience2508 Год назад +1

      you can watch mine too. The channel provides most of the fundamentals for Python and R, with downoadable source files.

    • @shvideo1
      @shvideo1 Год назад +1

      @@easydatascience2508 Thank you. I will. My new job requires a lot of Python and I’ve grown to like it very much. It has a very rich library base. Keep coding :)

  • @davidm.johnston8994
    @davidm.johnston8994 7 лет назад

    Thanks mr. Corey Schafer, very useful as usual!

  • @chaitanyayeturi1312
    @chaitanyayeturi1312 3 года назад

    First of all, your teaching style is good, and anyone grabs ur teachings easily, and thanks for teaching us. you are the best tutor I have ever come up with in python language. can u suggest any python language book, which is best to go through other than your channel? Moreover, I am a beginner to python language I thoroughly enjoyed ur videos, if u can suggest me best python book to ur sensibility and I guess it suits me and it helps me to learn further (I like physical like books). In case if u written any books related to this language can u suggest one (or) your favorite book, please......................................

  • @JeanMarieGalliot
    @JeanMarieGalliot 4 года назад +1

    Very clear, as always.

  • @jayh6429
    @jayh6429 7 лет назад +2

    Corey, Very nice and thanks for sharing.

  • @BSroad
    @BSroad 6 лет назад +1

    Thank you very much, mate! This video really helped me!

  • @soumyazyx
    @soumyazyx 5 лет назад +1

    Thank you Corey for your time and effort. Keep spreading the knowledge.

  • @user-pt4vn5hr2z
    @user-pt4vn5hr2z 5 лет назад +1

    you are the best, you help me a lot TNX.

  • @frameworklabs
    @frameworklabs 5 лет назад +2

    you are amazing, thanks for these awesome videos

  • @AllF1ne11
    @AllF1ne11 6 лет назад

    thankyou, you help me for PTI-B homework

  • @gopalchettytejaswi6692
    @gopalchettytejaswi6692 2 года назад +1

    At 8:30 why cannot we simply go as key = emp.name ? I did not understand the necessity of defining a new parameter. Corey please explain if you see this comment.
    Anyone else's advice is also appreciated. Thank you.

    • @saucegotti8538
      @saucegotti8538 Год назад

      this guy overcomplicates simple task for no reason

  • @stratan9707
    @stratan9707 9 лет назад +1

    Such an amazing tutorial! Keep up the good work brother!

  • @jimmyanderson9224
    @jimmyanderson9224 4 года назад

    you saved my life

  • @muyideenjimoh2874
    @muyideenjimoh2874 7 лет назад

    Video was head on. Thank you very much.

  • @buzz.b
    @buzz.b 2 года назад +1

    Very useful, thanks. In another video about comprehensions, it was suggested to use a comprehension in place of lambdas for readability. How could that be achieved with the example in this video?

  • @lilikoimahalo
    @lilikoimahalo 11 месяцев назад

    Awesome video 🎉

  • @siddharthasharma9316
    @siddharthasharma9316 4 года назад

    Key=Custom function -> lambda function->attrgettrer->itemgetter

  • @JoshuaDHarvey
    @JoshuaDHarvey 4 года назад

    Stupid question but @9:46, how does the e_sort function receive it's parameter? I don't see you passing any values to it so I have to assume, it's getting those from the first argument of sorted() which was 'employees'?

    • @fioo_2386
      @fioo_2386 4 года назад

      you should refer Corey's video regarding Variable scopes. he explains really thoroughly that topic

  • @justinstar9710
    @justinstar9710 7 лет назад

    as usual great tutorial, hopefully I can finish the whole series up to date!

  • @farahiyahsyarafina2183
    @farahiyahsyarafina2183 7 лет назад

    Great video. Thank you!!

  • @saeidsas2113
    @saeidsas2113 3 месяца назад

    Hi. In which video did you talk about the class? that line of code related to class Employee() seems has not been cover before this course 21. Thank you

  • @zorbagreek5556
    @zorbagreek5556 6 лет назад +5

    Hii corey
    When u defined e_sort (emp) how the function knows how to return instance variable from the class ? ,

    • @ShubhamKumar-vx8fm
      @ShubhamKumar-vx8fm 5 лет назад

      i have same question sir plzz answer

    • @thegamecracks1317
      @thegamecracks1317 5 лет назад +6

      The argument name "emp" does not reference the actual class. When the function is given as the "key" argument in the "sorted" function, "sorted" will run "e_sort" on each object in the iterable (the list) and pair the returned value to the objects, so that "sorted" will be able to use the values that actually know how to be sorted.
      In fact, the "e_sort" function as written in the video, will work on any object that has a "name" attribute, since the function only attempts to get the "name" attribute from the object it's given and doesn't care what actual type the object is.

    • @vedaantib8528
      @vedaantib8528 4 года назад

      @@thegamecracks1317 Thanks a lot for the clarification!!

  • @pratikbarve887
    @pratikbarve887 4 года назад

    Your videos are awesome really loved them . please add videos on some popular libraries like pygame,openpyxl etc.

  • @ivandrofly
    @ivandrofly 7 лет назад

    thank you so much :)... very informative videos

  • @ashutoshrath8810
    @ashutoshrath8810 7 лет назад

    God bless you Corey!!!

  • @jagannathgaidhani5333
    @jagannathgaidhani5333 7 лет назад +1

    you are just awesome man

  • @aimantabreez4888
    @aimantabreez4888 2 года назад

    Hey, at last you use the attrgetter method so what's the difference between the attrgetter and itemgetter

  • @jakelong0304
    @jakelong0304 4 года назад +2

    Im learning according to the order in the playlist. Suddenly "class"appears when you didn't mention it at all previously.

    • @kwiatriot6190
      @kwiatriot6190 4 года назад

      Same, but there are videos on that subject. Take a pause and find that one, they are all gems!

    • @shubhamthakur4751
      @shubhamthakur4751 4 года назад +1

      bro before watching these videos watch his beginners tutorial . I did the same it really clarifies everything

    • @fioo_2386
      @fioo_2386 4 года назад +1

      please note that these videos are not numbered, so there is no particular order on how watch them.. what matters here is to just get the basic idea. Just get the basics, and if needed you can come back at it anytime

  • @stefanopalliggiano6596
    @stefanopalliggiano6596 2 года назад

    Thank you for the video. Can the "sorted" built-in method deal with ties and break them according to another attribute. For example, in your Employee class, is it possible to write a function (as argument for the key parameter) that sorts according to age and, if there is a tie, then sorts according to salary?

  • @uguree
    @uguree 4 года назад +1

    Great, didnt understand why we give (emp) in e_sort function first then you put lambda i understand it, emp was unnecessary as a function param so lambda directly shortens first e_sort func in a shortest form

  • @william3588
    @william3588 5 лет назад +1

    on the function "e_sort()", how does salary, age or name is returned from the class?

  • @Panda-kn6zo
    @Panda-kn6zo 2 месяца назад

    Amazing vid

  • @ringo.gg.
    @ringo.gg. 8 лет назад +3

    Hey Corey I saw the string formatting video but I don't know why you use '$' on the salary placeholder in __repr__ function. Is it about some int to str stuff? because i'm kinda lost on this, sorry if it is a dumb question ! Your python tutorials are wonderful btw, hope you make a django / flask playlist one day too.

    • @coreyms
      @coreyms  8 лет назад +2

      Ringo gg Hey, that's a good question. It doesn't actually do anything in terms of formatting. If you look at the output when it's printed, it just added a dollar sign before the salary to signify it was a cash amount. But thanks for pointing that out because really I shouldn't have printed it out with a dollar sign within repr() since repr should usually be something you can use to recreate the object. That dollar sign may be a better output choice for str(). But to answer your question, it doesn't do anything in terms of formatting.

    • @ringo.gg.
      @ringo.gg. 8 лет назад

      oh thanks for reply so quickly ! I didn't notice the dollar sign af first because they are too close with each other and it has no space in it lol

  • @muntadher8087
    @muntadher8087 3 года назад

    Thank you!

  • @farisnaufal8579
    @farisnaufal8579 5 лет назад +1

    sorry i wanna ask, can i sorting value of list without change an index

  • @yogafinder1
    @yogafinder1 6 лет назад

    If you want name as primary sort and then age as secondary sort...how would you do that?

  • @a_maxed_out_handle_of_30_chars
    @a_maxed_out_handle_of_30_chars 3 года назад +1

    thank you :)

  • @alexbordei3951
    @alexbordei3951 5 лет назад

    If I had a large data set with many attributes, is there a way that I could turn them all into objects in bulk, so that I could then proceed to sorting the data in a certain way?

  • @illegalsmirf
    @illegalsmirf 2 года назад +1

    Absolutely amazing

  • @Saimelodies2512
    @Saimelodies2512 4 года назад

    How do you sort objects based on age first and then salary together, and suppose if ages are same and then, salary are same then sort with name .

  • @videofountain
    @videofountain 5 лет назад

    I am wondering if you should create a companion video for multiple key sort.

  • @КириллКириленко-ф6х

    Hey friend! Thx for you work. Can you explain me how do you delete # symbol in SublimeText with a single click? I use mac OS and I Don't know the hotkeys to delete symbols in the few string at once

  • @qzorn4440
    @qzorn4440 8 лет назад

    good info. thanks.

  • @vaidyts
    @vaidyts 8 лет назад

    This is very helpful, thank you!

  • @Dopeboyz789
    @Dopeboyz789 5 лет назад

    How do you match or intersection two multidimensional list of a list

  • @dellsantiago8108
    @dellsantiago8108 4 года назад

    More power by the way.

  • @zeitkapsel1
    @zeitkapsel1 2 года назад

    thanks bro!

  • @egorerofeev7762
    @egorerofeev7762 2 года назад +1

    Great tutorial. However, I get
    "TypeError: '

    • @easydatascience2508
      @easydatascience2508 Год назад

      maybe you can try str() for the number. You can see my channel too, it has a Python playlist, most of the fundamentals. Hope they will be helpful.

  • @sophea_sao
    @sophea_sao 5 лет назад

    Hi sir I use Pycharm for coding, but some keyword are not defined, and I try to use sublime text also but it still don't work. e.g print nums # which don't have parentheses.

  • @goodcompanycoffee
    @goodcompanycoffee 5 лет назад

    Great vid. How about a video on linked-list vs. arrays, and sort algorithms?

  • @showherdaad-din3733
    @showherdaad-din3733 4 года назад

    The key function described in this video takes only one argument. Say we need to sort based on employee name, then salary, then age. How will that work?

  • @stevefrt9495
    @stevefrt9495 7 лет назад

    Thanks you so much

  • @allenwu123
    @allenwu123 6 лет назад

    Thank you for the great videos!
    Could you explain why emp is used in the def e_sort? I don't see how it is calling/referring to anything in the class Employee. Thank you.

    • @edy3569
      @edy3569 6 лет назад +3

      Hi, emp is just the name he chose for the argument that is passed in the function.He could have also write def e_sort(abcdef):
      return abcdef.name
      and it would have worked the same.The point is that whatever you pass as parameter in the function,the function will return the value of the name attribute of that parameter(name being in this case the sorting criteria).So that function would have worked for any class that has a name attribute.So this function is just the sorting criteria of the sorted method.What connects this function to the employee class is these 2 lines of code:employees = [e1,e2,e3] and s_employees = sorted(employees,key=e_sort) (after of course creating e1,e2 and e3 as instances of the Employee class.)
      I know i'm late but I just started watching this series.Hope it helps

  • @PaintedMan924
    @PaintedMan924 5 лет назад

    @Corey Schafer
    First of all thank you for the videos and the amazing explanations!!! They have been a wonder. I would like to however find out what settings or packages you use to get the info on what it is that you are typing when coding. For example in this video at 0.56 while you are typing " s_li ".... it indicates that it is a statement. I have also seen that it does this for keywords and others as well. I have watched your video in configuring sublime text for python and have added the packages that work for me and have done the settings, however those settings have not added this functionality. Could you point me in the right direction so i can configure my sublime text to allow for this? Thank you

    • @fioo_2386
      @fioo_2386 4 года назад

      there is a separate video where he shows how to setup Sublime text for python development. ruclips.net/video/xFciV6Ew5r4/видео.html

  • @aleksandardevedzic6743
    @aleksandardevedzic6743 6 лет назад +1

    Im using python 3.6 and this does not work in my project, its like im trying to print the whole object:
    def e_sort(emp):
    return emp.name
    s_employee = sorted(employees, key=e_sort)
    print(s_employee)
    Can you tell me whats emp in def e_sort(emp) ?

    • @turdle69420
      @turdle69420 4 года назад

      Year late but whatever. When you call the function e_sort you pass in the parameter employees( the list-e1,e2,e3)Emp inside the function is a place holder variable for the entire list. Emp.name points to the name which was created in the class(which is now saved in employees list you passed through). Until you use the key=e_sort, the call to the built in function 'sorted' didn't know whether to sort by name, age or salary.
      Zero percent chance that made sense. Best of luck

  • @oguzturkyilmaz543
    @oguzturkyilmaz543 2 года назад

    Thank you

  • @aufcofficial8679
    @aufcofficial8679 8 лет назад

    Hie, suppose we have list of objects of class A with attributes (a1,a2,a3,...an). We want to sort this list of objects such that a1 should be maximum, a2 should be minimum, a3 should be maximum and so on. How should I proceed to write comparator function? Could you help?

    • @coreyms
      @coreyms  8 лет назад

      +Anurag Negi I'm not sure I understand. So let's say you had [a1,a2,a3,a4,a5,a6]. Would you want this sorted in this order: [a6,a1,a5,a2,a4,a3]? Alternating?

  • @omershehzad1730
    @omershehzad1730 3 года назад

    Hey @corey, is this formatting still valid in the latest python?

  • @turboromy
    @turboromy 7 лет назад +1

    Why can't employees be sorted ? I mean... is it because it is a class created object ? or is it because it have multiple values within them ?

    • @coreyms
      @coreyms  7 лет назад +1

      They can be sorted, but you just have to have a way to tell Python what you want the Employee to be sorted on. Because when you have an object with multiple attributes, it may not be obvious which attributes you would like to sort on.

    • @turboromy
      @turboromy 7 лет назад

      Thanks for quick replies. It really helps. I tend to forget my own question in a few days. While it is not very clear, I'll keep moving on and guess it'll be clear and too easy as I gain more knowledge.

  • @billimono4480
    @billimono4480 8 лет назад +2

    what text editor you are using? Looks cool

    • @TheOlian04
      @TheOlian04 8 лет назад

      Bill Deng likely sublime, or vs code, or atom

  • @shyamss2338
    @shyamss2338 3 года назад

    I have been following the python playlist and I am slightly confused by what was the use of the class here?

  • @MuzzyV29
    @MuzzyV29 7 лет назад

    why do you have to assign function (e_sort ) to a a key. Why can't we just assign .name method to key variable to pass all employees ? is it not possible without using anonymous or regular function ?
    Also does they Key variable has to be called KEY or is it just convention ?

  • @Soulfulreader786
    @Soulfulreader786 3 года назад

    How can we sort using earliest and latest datetime data
    Pls do reply..thanks

  • @chinmayjape4981
    @chinmayjape4981 5 лет назад

    Hello,
    Why we use init and repr as __init__ and __repr__... What is the logic behind putting the _ before and after them?

    • @coreyms
      @coreyms  5 лет назад +1

      Hey there. It’s a bit much to explain in a comment, but I have a video on this. If you search my channel for “magic methods”, then it should come up. Thanks.

    • @chinmayjape4981
      @chinmayjape4981 5 лет назад

      @@coreyms Thanks a lot!!! Will have a look in into it...

  • @glr3498
    @glr3498 Год назад

    What is dont understand is, how " e_sort" is linking to employees table.? We are not passing any argument in e_sort function.

  • @jayceazua723
    @jayceazua723 5 лет назад

    So with sorting objects what if the age is the same integer value, how can we switch it to sort based on the name alphabetically

  • @rupeshpokharel4405
    @rupeshpokharel4405 6 лет назад +1

    How can you use emp.name instead of employee.name when your class name is employee?
    How does it return the emp.name??
    Confused!!!

    • @coreyms
      @coreyms  6 лет назад +2

      Hey there. That is because the function is using a parameter named "emp". The employee object is passed into that function as an argument, and then that "emp" variable is equal to the employee object. If you watch my video on Function I go further into this concept. Hope that helps.

  • @musiclover21187
    @musiclover21187 8 лет назад

    Hey Corey, excellent videos. However, there is no linear progression playlist of python. For example, to understand this video, I had to check out classes in python. Can you make a linear playlist of python. Thanks!

  • @bing4060
    @bing4060 5 лет назад

    Hi, thank you for all your videos. How do you comments out a line or several lines?

  • @pa1kum6
    @pa1kum6 8 лет назад

    Thanks for the video, can you tell me how to sort dictionaries based on values?
    I came across this use case couple of times before and had to google it to get the logic. But would like to know how you would do this?

    • @coreyms
      @coreyms  8 лет назад +3

      Sorry to recommend the same answer you likely saw on StackOverflow, but that answer is the same way I would sort based on values:
      from operator import itemgetter
      x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
      sorted_x = sorted(x.items(), key=itemgetter(1))
      Link back to StackOverflow question:
      stackoverflow.com/questions/613183/sort-a-python-dictionary-by-value

    • @pa1kum6
      @pa1kum6 8 лет назад

      thank you, I have done something very similar
      sorted(my_dict.getitems(), key = lambda(x): x[1])

    • @surbhiagrawal3951
      @surbhiagrawal3951 4 года назад

      @@coreyms sorted_x=sorted(x.values())... will this alll work to sort the values of the dictionary

    • @Sudharsanan1989
      @Sudharsanan1989 2 года назад

      @@surbhiagrawal3951 in this only values were getting sorted and not the keys whereas our requirement is to sort both keys and values together.

  • @ullasgokarnkar5858
    @ullasgokarnkar5858 7 лет назад

    Hey ur videos r awesome can u make videos on data structure and algorithm

  • @krishnapodakula8509
    @krishnapodakula8509 6 лет назад

    can any one help me with out using built in functions can we write a code for ascending or descending order of dictionary based by values

  • @tonychen3306
    @tonychen3306 7 лет назад

    Can I replace e_sort after key as self.name?