Python Programming 13. Sorting a List

Publié le: 11 janvier 2022
sur la chaîne: Computer Science Lessons
3,113
56

This is the 13th in a course of computer science video lessons introducing programming with Python. This lesson follows on from the previous two lessons which introduced Python lists and how to iterate through a list using a loop. In this lesson you will learn how to sort a Python list. You will learn that this is easily done with the so called sort method, which will replace the existing list with a new sorted version of the list. You will also learn how to use the so called sorted method to sort a list, which leaves the original list unchanged, and generates a new list which is a sorted version of the original list. You will also learn how to sort a list into reverse order using the reverse parameter of the sort method. This lesson mentions the underlying algorithm of the Python sort method, namely, the Timsort which was invented by a computer scientist called Tim Peters. The Timsort first analyses the list to decide how best to sort it. Then, depending on the amount of data and the extent to which the list is already sorted, it employs either an insertion sort algorithm or a combination of the insertion sort and the merge sort.


Sur cette page du site, vous pouvez voir la vidéo en ligne Python Programming 13. Sorting a List durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Computer Science Lessons 11 janvier 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 3,113 fois et il a aimé 56 téléspectateurs. Bon visionnage!