Sorting array of string arrays by an element in the string array
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Oct 22 00:37:59 PDT 2014
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
More information about the Digitalmars-d-learn
mailing list