compareNaturalSort

Natural string comparison function for use with phobos's sorting algorithm

  1. bool compareNaturalSort(inout(dchar[]) a, inout(dchar[]) b)
    nothrow @safe pure
    bool
    compareNaturalSort
    (
    inout(dchar[]) a
    ,
    inout(dchar[]) b
    )
  2. bool compareNaturalSort(inout(char[]) a, inout(char[]) b)
  3. bool compareNaturalSort(inout(wchar[]) a, inout(wchar[]) b)

Return Value

Type: bool

true if a < b

Examples

assert(sort!compareNaturalSort(array(["0", "10", "1"])) == ["0", "1", "10"]);
assert(sort!compareNaturalSort(array(["a", "c", "b"])) == ["a", "b", "c"]);
assert(sort!compareNaturalSort(array(["a1", "a"])) == ["a", "a1"]);

Meta