Miles Sabin implemented a nice selection sort example in Scala's type system. See:
http://www.chuusai.com/2012/01/27/type-level-sorting-in-shapeless/
To get a better understanding how that works I ported the algorithm to Prolog.
selectleast([H|T], TM, [H|TRem]):-
selectleast(T, TM, TRem), TM < H.
selectleast([H|T], H, T).