Custom compare function for array.sort on an integer array?

Sequ user at example.net
Tue Apr 19 05:57:26 PDT 2011


Like the topic says, is it possible to set a custom compare function, for when
you are using the 'sort' property of an integer array? I want the integers to
be sorted by a different criteria than their natural order. From the
documentation (http://d-programming-language.org/arrays.html) I can see how it
would be done for structs or objects, but it doesn't seem to be possible for
primitive types.

If it can't yet be done, then I'm sure that adding the ability to give a
comparison function or lazy expression to the 'sort' call would be very
useful. Unless there is some reason that that would be beyond the scope of the
'sort' property's purpose?


More information about the Digitalmars-d-learn mailing list