On Friday, 29 June 2012 at 18:00:06 UTC, Timon Gehr wrote:
On 06/29/2012 07:52 PM, ixid wrote:
Or more generally does D have a library function so I can sort one array
based on sorting the contents of another?

sort!"a[0]<b[0]"(zip(basedOnThis, alsoSortThis));

This sorts both ranges in-place based on the contents of the first range.

Hello,

I have a similar problem, having statistics per class instance. How would I print out the statistics sorted ?

struct TestTuple {
    ...
}

int[TestTuple] stats;

foreach (test, stat; ??) {
    writeln(test, " = ", stat);
}

Please, what comes in ?? ? Your proposal sort!"a[0]<b[0]"(stats) does not compile in this place.

Thank you in advance,
Ludovit

Reply via email to