Answers for "python .sort key"

7

python sort

nums = [4,8,5,2,1]
#1 sorted() (Returns sorted list)
sorted_nums = sorted(nums)
print(sorted_nums)#[1,2,4,5,8]
print(nums)#[4,8,5,2,1]

#2 .sort() (Changes original list)
nums.sort()
print(nums)#[1,2,4,5,8]
Posted by: Guest on May-20-2020
6

sorting python array

sorted(list, key=..., reverse=...)
Posted by: Guest on September-23-2019

Python Answers by Framework

Browse Popular Code Answers by Language