Apl2ToDoSortingAlgorithms
This is a sub-page of PhraseBook/ToDo/Apl2Idioms
NM←NM[⍋NM;] ⍝ Sorting NM in ascending row order.
NM←NM[⍒NM;] ⍝ Sorting NM in descending row order.
NM←NM[⍋NM×I;] ⍝ Choosing sorting direction I +A, 0U, or -D.
CM←CM[SEQ⍒CM;] ⍝ Sorting CM in reverse SEQ order.
CM←CM[SEQ⍋CM;] ⍝ Sorting CM in SEQ row order.
M←M[⍒L/L;] ⍝ Sort by highfliers - M ←→ groups of length L.
V←V[⍋⍋IV] ⍝ Mesh V according to mask pattern IV.
V[⍋B]←V←X,Y ⍝ Mesh X and Y in V using boolean pattern B.
V←εX,¨Y ⍝ Merge X and Y alternately.
IV←⍋⍋NA ⍝ IV is the ranking of NA in same order.
IV[I]←IV←⍳⍴I←⍋NA ⍝ IV is the ranking of NA in same order.(fast)
(,A)←(,A)[⍋,A+(↑⌽⍴A)/(⌈/,A)×⍳×/¯1↓⍴A] ⍝ Sort each row in ascending order.
(,⍉A)←(,A)[⍋,A+(⍴A)⍴(⌈/,A)×⍳×/¯1↓⍴A] ⍝ Sort each column in ascending order.
A←⊃(⊂¨⍋¨A)⌷¨A←⊂[¯1+⍴⍴A]A←1/A ⍝ Sort each row in ascending order.
A←⊃(⊂¨⍋¨A)⌷¨A←⊂[⍴⍴A]A←1/A ⍝ Sort each row in ascending order.
A←⊃[I](⊂¨⍋¨A)⌷¨A←⊂[I←¯2+⍴⍴A]A ⍝ Sort each column in ascending order. 2≤⍴⍴A
A←⊃[I](⊂¨⍋¨A)⌷¨A←⊂[I←¯1+⍴⍴A]A ⍝ Sort each column in ascending order. 2≤⍴⍴A
V[⍋~B]←V←(B/X),(~B)/Y ⍝ Mask Operator. Merge X and Y using B.
V←(,BA)/,A ⍝ Pack an array into a vector based on BA.
((,BA)/,A)←V ⍝ Unpack a vector into an array based on BA.
APL Wiki