Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- def radixSort( listToSort, intLen ):
- leastSigFigIndex = intLen - 1
- if leastSigFigIndex < 0 :
- return listToSort
- sortingBins = [[],[],[],[],[],[],[],[],[],[]]
- tempSortingList = [];
- for sortable in listToSort:
- leastSigFig = int(str(sortable)[leastSigFigIndex])
- sortingBins[leastSigFig].append(sortable)
- for theBin in sortingBins:
- for sortable in theBin:
- tempSortingList.append(sortable)
- return radixSort( tempSortingList, leastSigFigIndex)
- someNumbers = [95,84,55,92,15,37,58,60,38,60]
- print( radixSort( someNumbers, 2 ) )
Add Comment
Please, Sign In to add comment