I generate an array of substrings with a given string and a substring length using this code:
function NthFrequencyCount(string,length){
var frequency = {};
for(var i = 0;i < string.length-length;i++){
var char = string.substring(i,i+length);
if(char.indexOf(' ') === -1){
if(frequency[char] === undefined)
frequency[char] = 1;
else
frequency[char]++;
}
}
return frequency;
};
The next thing that I would like to do is to sort the substrings by their frequencies.
How do I do that?