Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As others have said, you can use:

  sorted_list = sorted(my_list)

sorted() also has a reverse option and a key option to specify the keys to sort by.

And the sort is guaranteed to be stable.

https://docs.python.org/3/library/functions.html#sorted



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: