Advertisement
Guest User

Dragomir, 170183

a guest
Apr 10th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. numberList = [32, 37, 28, 30, 37, 25, 27, 24, 35, 55, 23, 31, 55, 21, 40, 18, 50, 35, 41, 49, 37, 19, 40, 41, 31]
  2.  
  3.  
  4. sortedNumberList = []
  5.  
  6.  
  7. # quicksort???
  8. length = len(numberList)
  9. for i in range(length):
  10.     number = numberList[i]
  11.     placed = False
  12.     for i2 in range(len(sortedNumberList)):
  13.             number2 = sortedNumberList[i2]
  14.             if number >= number2:
  15.                 sortedNumberList.insert(i2, number)
  16.                 placed = True
  17.                 break
  18.            
  19.     if placed is False:
  20.          sortedNumberList.append(number)
  21.        
  22.  
  23. # my implementation            
  24. print("My implementation of sort()",",".join(map(str, sortedNumberList)))
  25.  
  26. # checking if its correct, based on the sort() function
  27. print("Native sort()              ",",".join(map(str,reversed(sorted(numberList)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement