java.util.Arrays.sort(/* int, char, short, byte, boolean */) is implemented as a 'tuned quicksort' rather than a radix sort.
I did a speed comparison a while ago, and with something like n>10000, radix sort was always faster. why?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
I would speculate that:
The point is, it's not such a common use case, that it's optimization needs to be in the standard library. If you have written an application, that has performance issues, where you determine through profiling that sorting an array of 10000+ ints is actually the bottleneck, then you might as well write the sorting by hand or reconsider your choice of data structure in the first place.
Back2dos has said it all, I will just try to further clarify the point which I think is the most important:
Radix sort can only sort the actual primitive values that are contained within the array, based on their binary digit patterns. In actual real-world software engineering scenarios, this case is encountered almost never. What we tend to do far more often is sort arrays of more complex (non-primitive) data structures, and some times we sort arrays of indexes to other entities.
Now, an array of indexes to other entities is in fact an array of primitives, but the sort order is provided by the comparator interface (and/or delegate in C#) which compares not the indexes, but the entities indexed by the indexes. Thus, the sort order bears absolutely no relationship to the order of the values of the primitives, and therefore radix sort is absolutely useless for this scenario.
We have an array of strings: ="Mike", ="Albert", ="Zoro". Then we declare an array of indexes to those strings: =0, =1, =2. Then, we sort the array of indexes, passing it a comparator which compares not the indexes themselves, but the actual strings referred to by these indexes. After sorting, the resulting array of indexes will look like this: =1, =0, =2. As you can see, this sort order has nothing to do with the binary patterns of the values contained within the array, and yet by traversing this array of indexes and fetching each corresponding string, we visit the strings in sorted order.