How python sorts the elements in the list
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!