451. Sort Characters By Frequency
https://leetcode.com/problems/sort-characters-by-frequency/
Python
from collections import Counter
class Solution:
def frequencySort(self, s: str) -> str:
counts = [(char, count) for char, count in Counter(s).items()]
counts.sort(key=lambda item: item[1], reverse=True)
return ''.join([char*count for char, count in counts])