This problem is to sort an input string of N characters, N<1000000, based on the number of times a character occurs in the input. The most frequently occurring character should be sorted to the front of the string, followed by the next most frequently occurring character, etc. For characters occurring the same number of times, the character that occurs first in the input should be sorted to the front.
The infile input file contains the characters. Input characters other than those printable low ascii characters c, 0x20<c<0x7f, must be ignored.
Output specification
The outfile must be created and then filled with the sorted characters. It's final length should be exactly the same as the count of characters in the allowed range (0x20<c<0x7f) (which may be shorter than the infile file length).