-
Notifications
You must be signed in to change notification settings - Fork 28
Description
In theory, custom types defined in packages can implement any semantics for comparison and equality operators. This means that radix sort can be incorrect even for isbits types, if the comparison operators are inconsistent with the sorting of the bit pattern.
This is particularly dangerous since package authors do not necessarily consider the possibility of using RadixSort on their types, but users may do so naively without knowing the implementation details. AFAICT the only solution to prevent potentially problematic bugs is to throw an error by default when using RadixSort on a type which is not known to support it. A trait-like function SortingAlgorithms.radixsortsafe(::Type{T}) would have to be overridden to return true for types that support it. The error message could explain this, so that it is relatively easy to fix when users know what they are doing.