7. Quicksort Index   <<   >>
 

Q←{1≥≢⍵:⍵ ⋄ (∇ ⍵⌿⍨0>s)⍪(⍵⌿⍨0=s)⍪∇ ⍵⌿⍨0<s←⍵ ⍺⍺ ⍵⌷⍨?≢⍵}

   x ← ? 21⍴13
   x
3 2 3 9 0 11 4 2 1 9 9 1 4 8 7 9 3 1 1 5 7

   - Q x
0 1 1 1 1 2 2 3 3 3 4 4 5 7 7 8 9 9 9 9 11

   a  ← 'Fi' 'Jay' 'John' 'Morten' 'Roger'
   a ,← 'JD' 'Jd' 'Anna' 'Scott' 'Zeus'

   strcmp←{⍺≡⍵:0 ⋄ -/⍋↑⍺ ⍵}

   strcmp¨ Q a
┌────┬──┬──┬───┬──┬────┬──────┬─────┬─────┬────┐
│Anna│Fi│JD│Jay│Jd│John│Morten│Roger│Scott│Zeus│
└────┴──┴──┴───┴──┴────┴──────┴─────┴─────┴────┘