Answers for "python sorting array without inbuilt sort"

0

python sorting array without inbuilt sort

data_list = [-5, -23, 5, 0, 23, -6, 23, 67]
new_list = []

while data_list:
    minimum = data_list[0]  # arbitrary number in list 
    for x in data_list: 
        if x < minimum:
            minimum = x
    new_list.append(minimum)
    data_list.remove(minimum)    

print new_list
Posted by: Guest on September-06-2021
-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 sorting array without inbuilt sort"

Python Answers by Framework

Browse Popular Code Answers by Language