hybridSort

Perform either radix or standard sort depending on ElementType of Range.

hybridSort
(
alias less = "a < b"
Range
)
(
Range r
)
if (
isRandomAccessRange!Range
)

Examples

import std.meta : AliasSeq;
const n = 10_000;
foreach (ix, T; AliasSeq!(byte, short))
{
	import std.container : Array;
	import std.algorithm : isSorted, swap;
	import nxt.random_ex : randInPlace;

	auto a = Array!T();
	a.length = n;

	randInPlace(a[]);

	auto b = a.dup;

	hybridSort(a[]);
	assert(a[].isSorted);

	import std.algorithm.sorting : sort;
	sort(b[]);
	assert(b[].isSorted);

	assert(a == b);

	swap(a, b);
}

Meta