Answers for "python sort numbers ascending"

4

how to store sorted list into new variable in python

>>> numbers = [6, 9, 3, 1]
>>> numbers_sorted = sorted(numbers)
>>> numbers_sorted
[1, 3, 6, 9]
>>> numbers
[6, 9, 3, 1]
Posted by: Guest on July-01-2020
-1

sorting numbers in python without sort function

number=[1,5,6,9,0]
for i in range(len(number)):
  for j in range(i+1,len(number)):
    if number[i]<number[j]:
      number[i],number[j]=number[j],number[i]
print(number)
Posted by: Guest on February-05-2021

Code answers related to "python sort numbers ascending"

Python Answers by Framework

Browse Popular Code Answers by Language