Amazon Interview Question

Write a function to sort an input string based on their frequency.