sorting associative array's keys by values

Timon Gehr timon.gehr at gmx.ch
Sat Jun 16 09:44:31 PDT 2012


On 06/16/2012 06:41 PM, Timon Gehr wrote:
> On 06/16/2012 06:34 PM, maarten van damme wrote:
>> Right now I have an associative array "int[string] aa" and stored the
>> keys in "string[] keys".
>> Now I want to sort keys[] so that "aa[keys[0]]>aa[keys[1]]"
>> I remember someone gave the answer to that question on stackoverflow
>> but after some googling I couldn't find the right answer.
>>
>> maarten
>
> schwartzSort!(k=>aa[k])(keys);

oops.

Seems like you actually want

schwartzSort!(k=>aa[k],"a > b")(keys);


More information about the Digitalmars-d-learn mailing list