On Saturday, 7 June 2014 at 19:14:01 UTC, Chris Cain wrote:
This is my attemot to create a compare object. But I don't
know how to use it together with .sort member function
Don't use the .sort property. Use std.algorithm.sort, which has
a "less" predicate (that should return a bool).
http://dlang.org/phobos/std_algorithm.html#sort
Also note that the examples use a string to define the predicate,
but it accepts functions as well. Such as:
bool myCompareFunc(AType lhs, AType rhs)
{
return lhs.blah < rhs.blah;
}
//...
AType[] arr;
//...
arr.sort!myCompareFunc();