Guest User

Untitled

a guest
Feb 18th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. def radixSort( listToSort, intLen ):
  3. leastSigFigIndex = intLen - 1
  4.  
  5. if leastSigFigIndex < 0 :
  6. return listToSort
  7.  
  8. sortingBins = [[],[],[],[],[],[],[],[],[],[]]
  9. tempSortingList = [];
  10.  
  11. for sortable in listToSort:
  12. leastSigFig = int(str(sortable)[leastSigFigIndex])
  13. sortingBins[leastSigFig].append(sortable)
  14. for theBin in sortingBins:
  15. for sortable in theBin:
  16. tempSortingList.append(sortable)
  17. return radixSort( tempSortingList, leastSigFigIndex)
  18.  
  19.  
  20.  
  21. someNumbers = [95,84,55,92,15,37,58,60,38,60]
  22. print( radixSort( someNumbers, 2 ) )
Add Comment
Please, Sign In to add comment