Grade & Sort Index   <<   >>


 
tgr    ← {⊃ {⍵[⍋(⊂⍵)⌷⍺]}/ ⍵,⊂⍳≢⊃⍵}
tgr1   ← {⍋ ⍉ ↑ {(⍋⍋⍵)[⍳⍨⍵]}¨ ⍵}

torder ← {0=⎕nc '⍺':tgr ⍵ ⋄ (tgr ⍵)tindex ⍺}

torder T         ⍝ grade T
torder T[1 0]    ⍝ grade columns 1 and 0 of T
T torder T       ⍝ ←→ torder⍨ T; sort T
T torder T[1 0]  ⍝ order T according to columns 1 and 0

tgr ⠴ {(tgr ⍵) tindex ⍺}
tgr ⠴ ((tgr ⊢) tindex ⊣)
monadic ⠴ dyadic  ⍝ an operator; ⠴ ←→ U+2834