Answers for "sort in python'"

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
8

python sort list

vowels = ['e', 'a', 'u', 'o', 'i']
vowels.sort()
Posted by: Guest on May-15-2020
0

sort in python'

arr = [1,4,2,7,5,6]
#sort in ascending order
arr = arr.sort() 

#sort in descending order
arr = arr.sort(reverse = True)
Posted by: Guest on July-08-2020
0

how to sort a list in python

old_list = [3,2,1]
old_list.sort()
Posted by: Guest on June-22-2020

Python Answers by Framework

Browse Popular Code Answers by Language