Home >Backend Development >Python Tutorial >How to sort ascending and descending order in python

How to sort ascending and descending order in python

angryTom
angryTomOriginal
2020-03-02 16:42:1627920browse

How to sort ascending and descending order in python

Recommended: "python video tutorial"

1 , First open the cmd command prompt, enter the command "ipython" to open the python command line tool:

How to sort ascending and descending order in python

2. First define a variable number array in the command line, and write in it Enter several numbers, use the sorted function to sort the numbers, and assign the sorted result to variable a. The first parameter of the sorted function is the parameter to be sorted, and the second is the fixed parameter reverse, which means reverse order. True is turned on:

How to sort ascending and descending order in python

#3. Finally print out the a scalar, which is output in descending order:

How to sort ascending and descending order in python

For more related questions, please pay attention PHP Chinese website!

The above is the detailed content of How to sort ascending and descending order in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn