Answers for "python sorted ascending"

2

python sorted ascending

sorted_list = sorted(list)					# ascending (default)
sorted_list = sorted(list, reverse=True)    # descending
Posted by: Guest on May-13-2021
47

python sort list

# sort() will change the original list into a sorted list
vowels = ['e', 'a', 'u', 'o', 'i']
vowels.sort()
# Output:
# ['a', 'e', 'i', 'o', 'u']

# sorted() will sort the list and return it while keeping the original
sortedVowels = sorted(vowels)
# Output:
# ['a', 'e', 'i', 'o', 'u']
Posted by: Guest on February-18-2020

Python Answers by Framework

Browse Popular Code Answers by Language