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!!!
Nesta página do site você pode assistir ao vídeo on-line Python Programming: Lesson 49 - Sortable Objects duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário youmils03 29 Setembro 2021, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 69 vezes e gostou 0 espectadores. Boa visualização!