Want to suggest a small improvement in the solution for Radix Sort Challenge
The challenge is to implement MSD radix sort.
(Ch.31; Page: 365)
The current base case checks if the position is valid for the maximum number:
guard position < array.maxDigits else {
return array
}
My suggestion is to include (array.count > 0) in the base case. This means that we don’t need to sort the bucket if it contains only one element. This significantly reduces the number of passes as eventually a lot of buckets only contain only one Integer.
Suggested base case
guard array.count > 1 && position < array.maxDigits else {
return array
}