Salesforce interview question

Josephus problem Sort string by frequency of characters