I was looking at the
APL idiom library 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