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

2014-10-22 Thread bearophile via Digitalmars-d-learn
Neal: Interesting! Thank you. Memory isn't a problem Unfortunately currently the sort-decorate-undercorate in Phobos is not very fast. 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? There is far more th

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

2014-10-22 Thread Neal via Digitalmars-d-learn
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, consid

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

2014-10-22 Thread bearophile via Digitalmars-d-learn
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!

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

2014-10-21 Thread neal via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 01:58:19 UTC, neal wrote: On Wednesday, 22 October 2014 at 01:02:17 UTC, bearophile wrote: neal: Anybody have any suggestions? Something like this, perhaps? data.sort!q{ a[4] > b[4] }; Bye, bearophile Hmmm.. Im getting some interesting results here. So wh

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

2014-10-21 Thread neal via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 01:02:17 UTC, bearophile wrote: neal: Anybody have any suggestions? Something like this, perhaps? data.sort!q{ a[4] > b[4] }; Bye, bearophile Hmmm.. Im getting some interesting results here. So when i put all of the populations in an area and used this cod

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

2014-10-21 Thread bearophile via Digitalmars-d-learn
neal: Anybody have any suggestions? Something like this, perhaps? data.sort!q{ a[4] > b[4] }; Bye, bearophile

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

2014-10-21 Thread Joel via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 00:32:56 UTC, neal wrote: Just curious if this is possible. I have some data on different countries that i have stored in a multidimensional array called data[][]. What I want to do is sort data[][] by population which happens to be stored in data[i][4] where i

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

2014-10-21 Thread Joel via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 00:36:22 UTC, Joel wrote: On Wednesday, 22 October 2014 at 00:32:56 UTC, neal wrote: Just curious if this is possible. I have some data on different countries that i have stored in a multidimensional array called data[][]. What I want to do is sort data[][] by

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

2014-10-21 Thread neal via Digitalmars-d-learn
Just curious if this is possible. I have some data on different countries that i have stored in a multidimensional array called data[][]. What I want to do is sort data[][] by population which happens to be stored in data[i][4] where i is the index to iterate from country to country. I would