Here is my solution. Note that this is cool, like FeepingCreature, but probably easier to understand; it works by recursively inserting the first type into the rest of the list (after sorting it).
module sort; import std.typetuple; struct Val(string v_) { static const v = v_; } template Sorted_impl(T) { alias TypeTuple!(T) Sorted_impl; } template Sorted_impl(T, U, V...){ static if( Tv < Uv ) alias TypeTuple!(T, U, V) Sorted_impl; else alias TypeTuple!(U, Sorted_impl!(T, V)) Sorted_impl; } template Sorted(T) { alias TypeTuple!(T) Sorted; } template Sorted(T, U...) { alias Sorted_impl!(T, Sorted_impl!(U)) Sorted; } pragma(msg, Sorted!(Val!("a")).stringof); pragma(msg, Sorted!(Val!("b"), Val!("a")).stringof); pragma(msg, Sorted!( Val!("d"), Val!("a"), Val!("b"), Val!("c") ).stringof); static assert( false, "nothing to compile here, move along..." );
source share