Get the App
SLTechnology News&Howtos  ›  Development  › 

How python sorts the elements in the list

Shulou Source: shulou.com Published: 2022-06-01 03:24:25 09月22日 Update

This article mainly introduces python how to sort the elements in the list, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

Example:

# sort: sort by default, list2= in ascending order for numbers [2 print 4 list2.sort 1 list2 1 list2.sort 9 22 11 8] print (list2) list2.sort (reverse=True) print (list2)

# results:

# [- 1,1,2,4,8,9,11,22]

# [22, 11, 9, 8, 4, 2, 1,-1]

Thank you for reading this article carefully. I hope the article "python how to sort the elements in the list" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Articles sorting elements value interest ascending order at the same time numbers more friends knowledge examples results editing industry information information channels channels references learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Information Linux NVidia Docker