Function compareNaturalSort

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

bool compareNaturalSort(T) (
  const T a,
  const T b
)
if (isSomeString!T);

Returns

true if a < b

Example

import std.algorithm : sort, equal;
import std.array : array;
assert(compareNaturalSort("a", "b") == true);
assert(equal(sort!compareNaturalSort(["0", "10", "1"]), ["0", "1", "10"]));
assert(equal(sort!compareNaturalSort(["a", "c", "b"]), ["a", "b", "c"]));
assert(equal(sort!compareNaturalSort(["a1", "a"]), ["a", "a1"]));