Python How To Sort a List - Strings, Numbers, and Dictionaries Sorted Up, Down, or Using Functions!

preview_player
Показать описание
In this Python beginner Tutorial we are using the Pycharm IDE and Python version 3. We go in depth on how to use python's built in sort() function to manipulate data in lists.

Strings in lists default to being sorted alphabetically, while integer or float numerical values default to being sorted from smallest values first to highest values last. We show in this video how you can use the reverse option when sorting lists to switch it such that the smallest values come last and largest come first or sort in reverse alphabetical.

Next we demonstrate how to use a function to sort a list by a value that is not the default method for that data type. We begin by sorting a list of strings by the length of the entry, but follow by sorting a list compiled of dictionaries and sort by the value of a specific key!

There are tons of uses for sorting lists and hopefully this covered what you needed, but if you have any additional questions or want to see something specific next just let us know in the comments!

Check out the channel for lots more python tutorials and fun content including building games and apps using python!
Рекомендации по теме