PLEASE SUBSCRIBE!!!
In the previous lesson ( • Python Programming: Lesson 48 - Bubble Sort ), we gained exposure to a new algorithm called bubble sort. This is a relatively inefficient but easy-to-understand approach to sorting the elements in a list of SORTABLE elements. In this video, we spend some time reviewing bubble sort, but we do it in the context of generally sortable objects (instances of the Person class) rather than with ints or floats. In the next video, we will study insertion sort and selection sort from an object-oriented perspective.
Recall that we can use the _lt_ magic method to define what it means for one instance of a class to be less than another instance of a class. This is essentially when we attempt to sort a collection of elements that belong to a particular class. Try using bubble sort to sort a collection of Person objects, or Car objects, or Hamburger objects. How do you define __lt__? How do you code bubble sort? (See the previous video: • Python Programming: Lesson 48 - Bubble Sort )
2:07 Review of Lambda Functions and the del Keyword
6:55 Review of the pass Keyword
8:20 Review of Bubble Sort
12:16 NEW: Sortable Objects with the _lt_ Magic Method
Using _lt_ to compare instances of a class is kinda like using the compareTo( ) method in Java: • Java Programming: Lesson 36 - Modified Con...
Ready for another sorting algorithm called insertion sort? Check it out here: • Python Programming: Lesson 50 - Insertion ...
Thanks for watching, and PLEASE SUBSCRIBE!!!
On this page of the site you can watch the video online Python Programming: Lesson 49 - Sortable Objects with a duration of hours minute second in good quality, which was uploaded by the user youmils03 29 September 2021, share the link with friends and acquaintances, this video has already been watched 69 times on youtube and it was liked by 0 viewers. Enjoy your viewing!