www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How would I sort an associative array by value?

reply "ixid" <nuaccount gmail.com> writes:
Or more generally does D have a library function so I can sort 
one array based on sorting the contents of another? I don't want 
to just sort the values alone, the associated keys would need to 
move with them. I can think of ways of doing it myself, just 
wondering if there's an elegant way built in.
Jun 29 2012
next sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
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.
Jun 29 2012
prev sibling parent "ixid" <nuaccount gmail.com> writes:
Thank you!
Jun 29 2012