Sorting array of string arrays by an element in the string array

Neal via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 22 10:57:31 PDT 2014


On Wednesday, 22 October 2014 at 07:38:01 UTC, bearophile wrote:
> neal:
>
>> data.sort!q{ to!int(a[4]) > to!int(b[4]) };
>>
>> This code fixes my problem! Thanks for the quick responses 
>> guys. you rock!
>
> That converts string->int many more than once for each string. 
> So if memory is not a problem, consider using a 
> decorate-sort-undecorate pattern:
>
> data.schwartzSort!q{ a[4].to!int };
>
> Bye,
> bearophile

Interesting! Thank you. Memory isn't a problem but I would still
like to learn how to write more efficient programs. If i posted
my code would you be able to give me some advice?


More information about the Digitalmars-d-learn mailing list