In the radix sort code remainingPart
is calculated like so:
let remainingPart = number / digits
So if the number is 1772 and the digits are 1000, then the remaining part will be 1. However, when you check whether to go for another round, you check like this:
if remainingPart > 0 {
done = false
}
Since remainingPart
is 1, this causes the while loop to do another unnecessary round for the 10000 digits.