XYZ interview question

Sort the array using frequency