stable_radix_sort - Sort elements in ascending order.
Declared in <folly/algorithm/StableRadixSort.h>
template<typename ContiguousIt>
void
stable_radix_sort(
ContiguousIt first,
ContiguousIt last);
Sorts elements using LSD radix sort. This is a stable sort: elements with equal keys preserve their original relative order.
Note: For floating-point types, the sort uses an augmented ordering equivalent to std::stable_sort(first, last, augmented_less) where:
template <std::floating_point T> struct augmented_less { bool operator()(T lhs, T rhs) const noexcept { if (lhs < rhs) return true; if (rhs < lhs) return false; return std::signbit(lhs) > std::signbit(rhs); } };
In other words, -0.0 sorts before +0.0. For all other values, the ordering matches operator<.
Requirements:
ContiguousIt must be a contiguous iterator
Value type must be floating-point or integral
Complexity: O(n * k) where k = sizeof(value_type) / 8 Space: O(n) for temporary buffer
| Name | Description |
|---|---|
| first | Iterator to the first element to sort. |
| last | Iterator past the last element to sort. |