nest.sortKeys()

nest.sortKeys(comparator)

Sorts key values for the current key using the specified comparator function, such as d3.ascending or d3.descending. If no comparator is specified for the current key, the order in which keys will be returned is undefined. For example, to sort years in ascending order and varieties in descending order:

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

Note that this only affects the result of nest.entries; the order of keys returned by nest.map and nest.object is always undefined, regardless of comparator.

doc_D3_Js
2016-11-24 10:28:08
Comments
Leave a Comment

Please login to continue.