Python Programming 13. Sorting a List

Опубликовано: 12 Январь 2022
на канале: Computer Science
3k
52

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.


Смотрите видео Python Programming 13. Sorting a List онлайн без регистрации, длительностью 05 минут 58 секунд в хорошем hd качестве. Это видео добавил пользователь Computer Science 12 Январь 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 3 тысяч раз и оно понравилось 52 людям.