Zipped sorting

2012-09-24 Thread bearophile
This line of code sorts two arrays in "lock step", according to the items of the first array: zip(first, second).sort!q{a[0] < b[0]}(); This code is handy, nice looking, short and sufficiently easy to recognize once you have seen it before. It's one case where D code is better than a Python

Re: Zipped sorting

2012-09-24 Thread cal
On Tuesday, 25 September 2012 at 02:17:53 UTC, bearophile wrote: This line of code sorts two arrays in "lock step", according to the items of the first array: zip(first, second).sort!q{a[0] < b[0]}(); Tangential to your point, but I hadn't seen the q{} syntax used before. Are there reasons t

Re: Zipped sorting

2012-09-24 Thread Dmitry Olshansky
On 25-Sep-12 06:18, bearophile wrote: This line of code sorts two arrays in "lock step", according to the items of the first array: zip(first, second).sort!q{a[0] < b[0]}(); This code is handy, nice looking, short and sufficiently easy to recognize once you have seen it before. Analyzing asm

Re: Zipped sorting

2012-09-25 Thread bearophile
Dmitry Olshansky: Analyzing asm dump should help. In this case it's a good amount of asm code. But either way zip-sort heavily relies on proper inlining and I suspect it's not fully "unrolled". I don't know if that's enough. Did you try DMD or other compilers? In past I have used LDC

Re: Zipped sorting

2012-09-25 Thread Dmitry Olshansky
On 25-Sep-12 15:23, bearophile wrote: Dmitry Olshansky: Analyzing asm dump should help. In this case it's a good amount of asm code. This sounds like you are not interested in the cause of this at all ;) I've dig it and it looks mostly fine. However for a small number of elements it will

Re: Zipped sorting

2012-09-27 Thread bearophile
Dmitry Olshansky: This sounds like you are not interested in the cause of this at all ;) Right, this I was a little lazy, because I was a bit depressed because of similar problems. I will do more tests. Later, bearophile