#Dyalog APL, 24 bytes

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

[Try it online!](http://tryapl.org/?a=%7B2%u22A5%A8%u2193%u2349%u2191%7B%u2375%5B%u234B%u2375%5D%7D%A8%u21932%u22A5%u2363%AF1%u22A2%u2375%7D10%2017%2019%2023&run)