Referencing yesterday's discussion about ⍤, I realised that I can use it to
get the indexes like this:
*X*
┌→─┐
↓xz│
│zx│
│ab│
│ba│
└──┘
*⍋⍤1 X*
┌→──┐
↓1 2│
│2 1│
│1 2│
│2 1│
└───┘
However, I can't figure out a good way to apply it to the original array.
Really, what is th ebest solution to this problem?
Regards,
Elias
On 5 March 2014 13:06, Elias Mårtenson <[email protected]> wrote:
> I was looking at the APL idiom
> library<http://aplwiki.com/FinnAplIdiomLibrary>and found this solution to
> sort rows in a matrix X:
>
> A←(⍋,X)-⎕IO ◊ (⍴X)⍴(,X)[⎕IO+A[⍋⌊A÷¯1↑⍴X]]
>
>
> It looked a bit excessive to me, and I wanted to make a more clear version
> so I came up with this:
>
> ⊃p⌷¨⍨⊂¨⍋¨p←⊂[2]X
>
>
> Are there any benefits to the previous one?
>
> As a side note, since I'm a big fan of lambda functions, I find my second
> solution to be even better, but the idiom library doesn't use lambdas so
> it'd be a bit of apples vs. oranges:
>
> ⊃ {⍵[⍋⍵]}¨ ⊂[2]X
>
>
> Opinions?
>
> Regards,
> Elias
>
>