current position:Home>[Python] sort and sorted

[Python] sort and sorted

2022-05-15 05:57:23__ Watson__

sort() yes list The way to go , Yes list Self modification
ls = []
ls.sort()
ls Itself is changed

sorted() yes Python Built in sorting method , Return another sorted result , Do not change the original data ,sorted The content is not just list, It can also be other iteratable objects .
sorted(ls)

copyright notice
author[__ Watson__],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/131/202205110609599136.html

Random recommended