- [Instructor] One of the main downsides…of the regular dictionary object in Python…is that it doesn't keep track of any order among the items.…The OrderedDict is a dictionary object…that remembers the order in which items are inserted,…and we'll take a look at that in this example now.…So I'm going to open up the ordereddict_start file…here in my Collections folder.…And here in my code, I have a list of tuples,…each of which represents a sports team,…along with a tuple that contains their win and loss record.…
And I'm using the built-in sorted function…to sort the list by the number of wins.…And we saw this function earlier in the course.…And you can see that the key function I'm using here…is a lambda function, which is getting the first item…in the embedded tuple here to sort by the number of wins.…And you can also see that I'm using an OrderedDict.…I'm importing OrderedDict here from the collections,…from the Collections module.…
And what I'm going to do first is I'll use this list…of tuples to initialize an OrderedDict object.…
- Truth value testing
- Template strings
- Advanced Python functions
- Advanced collections
- Advanced classes and objects
- Python comprehensions: list, dictionary, and set
Skill Level Advanced
1. Python Language Features
2. Built-In Functions
3. Advanced Python Functions
4. Advanced Collections
5. Advanced Classes and Objects
6. Using Logging
7. Python Comprehensions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.