We’re rewarding the question askers & reputations are being recalculated! Read more.
1 of 5

Dyalog APL, 22 bytes

{2⊥¨{⍵[⍋⍵]}¨↓⍉2⊥⍣¯1⊢⍵}

Try it online!