15,745,620 members
See more:
I am creating a program that sorts the user's input in increasing and decreasing order... I have tried the sorted() function but it would only sort 1 number.

What I have tried:

Python
```list=input("Enter your list:")
print("Unsorted:", list.split())

a=list
print("Sorted Ascending Order:")
print sorted(a)

print("Sorted Descending Order:")
print sorted(a, reverse=True)```

In my code, I tried to sort 35,5 and 4 but the result would be like this:
`['3','4','5','5']`
Posted
Updated 13-Apr-21 1:03am
v3

## Solution 1

The following program (`Python 3`)
Python
```s = input()
lnum = list(map(int, s.split()))

print("Unsorted:", lnum)

print("Sorted Ascending Order:")
print (sorted(lnum))

print("Sorted Descending Order:")
print(sorted(lnum, reverse=True))```

executes this way
```35 5 4
Unsorted: [35, 5, 4]
Sorted Ascending Order:
[4, 5, 35]
Sorted Descending Order:
[35, 5, 4] ```

lil_mint 13-Apr-21 10:34am
Thank you very much, this helps a lot..
CPallini 13-Apr-21 10:50am
You are welcome.
Maciej Los 13-Apr-21 15:52pm
5ed!
CPallini 14-Apr-21 1:45am
Thank you!