d3-collection

https://github.com/d3/d3-collection

Table of Contents

Objects

d3.keys(object)

d3.values(object)

d3.entries(object)

Nests

Think of it like the GROUP BY operator in SQL, except you can have multiple levels of grouping, and the resulting output is a tree rather than a flat table.

d3.nest()

nest.key(key)

nest.sortKeys(comparator)

Data:
var entries = d3.nest()
    .key(function(d) { return d.year; }).sortKeys(d3.ascending)
    .key(function(d) { return d.variety; }).sortKeys(d3.descending)
    .entries(yields);
Result:

nest.sortValues(comparator)

nest.rollup(function)

d3.nest()
  .key(d => d.name)
  .rollup(v => v.length)
  .entries(data);

nest.map(array)

nest.object(array)

nest.entries(array)

Sort by rollup keys or values howto

Sort by rollup keys
Sort by rollup values