peterschussheim
11/8/2016 - 7:00 PM

charCount2

charCount2

const charFrequency = (string) => {
  let count = {};
  string.split('').forEach(function(c) {
    if (count[c]) {
      count[c] += 1;
    } else {
      count[c] = 1;
    }
  });
  let keys = Object.keys(count);
  let mapped = keys.map((key) => [key, count[key]]);
  
  return mapped;
};

const sortAsc = (a,b) => {
	 a – b;
};

var charM = charFrequency("mississippi").sort(sortAsc)


// [ [ "i", 4 ], [ "s", 4 ], [ "p", 2 ], [ "m", 1 ] ]

var charMississippi = charFrequency("mississippi").sort(letterComparator)
var sort = charMississippi.sort(numComparator)

charCount2

This Gist was automatically created by Carbide, a free online programming environment.

You can view a live, interactive version of this Gist here.