text into piles: equal characters must stand next to each other, and the piles go from the largest to the smallest (a pile's size is how many times its character occurs in text).
If two piles have the same size, the one whose character appears earlier in text goes first. Uppercase and lowercase letters count as different characters.
Return the resulting string.text="banana" → 'aaannb'
a occurs 3 times, n twice and b once, so the answer is "aaannb".
text="xyz1y" → 'yyxz1'
yy comes first. The other characters occur once each, so they follow in order of first appearance: x, z, 1.
text="Mm" → 'Mm'
M and m are different characters, one each; M shows up first.
text consists of English letters (upper and lower case) and digitstext="banana"
'aaannb'
Run checks the first 3 tests in your browser. Submit checks all 52 tests on the server, hidden ones included.