Sorting strings vs. integers in Python

preview_player
Показать описание
Sorting follows fairly simple rules in Python, but they can sometimes lead to confusing results. For example, if you try to sort a list of strings, where the strings contain only digits, you might be rather surprised by the results. In this video, I explain what's going on, why sorting works the way it does, and how you can solve the problem using either list comprehension or the "key" parameter for sorted.

Рекомендации по теме
Комментарии
Автор

"Even though I should always come first" was so funny hahaha. And well yes! of course!!

junniiee-mdtl
Автор

Hi, how to write difficulty levels of an exam (such as easy, medium, hard) and ask users to select a difficulty level? Thanks

pparish
Автор

Thanks, would edit the title to "Sorting numbers as strings vs. numbers as integers in Python"

phil
Автор

Could you sort the repetitive numbers given by a int input of the user, using only loops? Like if given number 200203719, it must be arrange 000122379

jennyking