For every iteration, radix sort renders a version of the input list that is sorted based on the digit that was just looked at. At first pass, only the ones digit is sorted. At the second pass, the tens and the ones are sorted. This goes on until the digits in the largest position of the largest number in the list are all sorted, and the list is sorted at that time.
Here we’ll be rendering the list, at first, it will just return the list sorted so just the ones digit is sorted.
Outside of our for loop which appends the
numbers in our input list to the different buckets in
digits, let’s render the list.
Since we know that all of our input numbers are in
digits we can safely clear out
being_sorted. We’ll make it an empty list and then add back in all the numbers from
digits as they appear.
Assign an empty list to
Now, create a for loop that iterates through each of our lists in
Call each of these lists
numeral because they each correspond to one specific numeral from 0 to 9.
Now use the
.extend() method (which appends all the elements of a list, instead of appending the list itself) to add the elements of
Unindent out of the for loop and return