[Solved] Sort Arrays By Their Length


var
  a = ["a", "a"];
  b = ["b", "b", "b", "b"],
  c = ["c", "c", "c"],
  d = ["d"],
  container = [a, b, c, d];

​container.sort(function (a, b) {
  return b.length - a.length;
});

console.log(container);

container will be sorted from longest (most elements) to shortest (least number of elements). Access it as:

container[0] // longest
container[1] // 2nd longest
// ...

http://jsfiddle.net/pSRVq/

0

solved Sort Arrays By Their Length