Answers for "sorting a list with a limited class python"

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
0

python sort multiple keys

records.sort(
  key = lambda l: (l[0], l[2])
)
Posted by: Guest on April-04-2020

Code answers related to "sorting a list with a limited class python"

Python Answers by Framework

Browse Popular Code Answers by Language