# Leetcode 451 - Sort Characters By Frequency

Note:

• TIL that Map or Set can be converted into arrays through ES6 [...map] ([key, val] pairs) or [...set].
• So if we just use map, we can quickly convert map into sortable array.

Question:

Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string.

Return the sorted string. If there are multiple answers, return any of them.

Example:

Code:

Naive Way using array