XYZ Interview Question

Sort the array using frequency