Sort

Sorts L in ascending order according to cmp.

cmp can evaluate to:

  • $(D_KEYWORD bool): $(D_KEYWORD true) means ai < a[i + 1].
  • $(D_KEYWORD int): a negative number means that ai < a[i + 1], a positive number that ai > a[i + 1], 0 if they equal.

Merge sort is used to sort the arguments.

template Sort (
alias cmp
L...
) if (
__traits(isTemplate, cmp)
) {}

Members

Aliases

Sort
alias Sort = L
Undocumented in source.
Sort
alias Sort = merge!(0, 0)
Undocumented in source.

Parameters

cmp

Sorting template predicate.

L

Elements to be sorted.

Return Value

Elements of L in ascending order.

Examples

enum cmp(T, U) = T.sizeof < U.sizeof;
static assert(is(Sort!(cmp, long, short, byte, int)
           == AliasSeq!(byte, short, int, long)));

See Also

Meta