Issue #3556987 by phenaproxima, penyaskito, fathershawn: Add a recursive sort-by-key function to SortArray (cherry picked from commit 5071f112)