For applicable data types a good radix sort can beat the pants off comparison sorts by a wide margin but std::sort
is usually implemented as introsort. Is there a reason to not use radix sort to implement std::sort
? Radix sort doesn't fully suffice for implementing std::sort
because std::sort
requires only that types be comparable but for types where comparison and radix based sorting produce the same answer (e.g. int
) this seems like low hanging fruit that's been left unplucked.
Would it be legal to implement std::sort
with overloads that use radix sort when appropriate? Is there something about the requirements of std::sort
that fundamentally prevent this?
Edit: I should have been a tad more clear. I'm asking if it would be legal for an implementation of the standard library to do this. I'm not asking about a user of a standard library implementation placing anything in the std
namespace. I know that doing so is illegal except in specific cases.