+ 1

Sort inputs in ascending and descending order.

Say I wanna input as many numbers as I want, then sort them in ascending or descending order, how would I go about that? Also need help with the pseudocode of it if possible.

5th Mar 2019, 12:34 PM
Ryan Savige
Ryan Savige - avatar
2 Antworten
+ 3
Step 1 : Read integers using input() function ([int(i) for i in input().split()]) and assign it to a list Step 2 : print your list to check the data using print() Step 3 : use sorted() function to sort your list asc Step 4 : print the sorted asc data Step 5 : use sorted() function with attribute reverse=True to sort descending your list Step 6 : print the sorted desc data I hope it helps
5th Mar 2019, 1:07 PM
Prokopios Poulimenos
Prokopios Poulimenos - avatar
+ 13
Have you tried something ? If you did, could you please post your attempt here ?
5th Mar 2019, 12:51 PM
Uni
Uni - avatar