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:
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:
#3. Finally print out the a scalar, which is output in descending order:
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!