A sorting network here is probably what would be most efficient given the low number of arguments, and the fact that their number is compile-time known (no loop conditions).
bubble sort lends itself well to being sort network'ed. I threw this together. It works and is really simple:
import std.stdio, std.string;
void bubbleSort(T...)(ref T values)
{
static if (T.length > 1)
{
foreach(I, _; T[0 .. $ - 1])
{
pragma(msg, format("[%s %s]", I, I + 1));
compareAndSwap(values[I], values[I + 1]);
}
bubbleSort(values[0 .. $ - 1]);
}
}
void compareAndSwap(T)(ref T a, ref T b)
{
import std.algorithm;
if(a > b)
swap(a, b);
}
void main()
{
int a = 10;
int b = 30;
int c = 11;
int d = 20;
int e = 4;
int f = 330;
int g = 21;
int h = 110;
shellSort(a, b, c, d, e, f, g, h);
writefln("%s %s %s %s %s %s %s %s!", a, b, c, d, e, f, g, h);
}
Although to be honest, if this was standard library, any sorting network of less than 10 arguments should be hand written.
EDIT: I completely changed the previous algorithm, which was actually highly ineficient. Bubble sort is not optimal, but it actually works OK for sorting algorithms. There's some pragmas in there to see the network that's built.