Public
Edited
Oct 13, 2023
Fork of d3.groupSort
Insert cell
Insert cell
barley = FileAttachment("barley.csv").csv({ typed: true })
Insert cell
Insert cell
d3
.rollups(
barley,
(group) => d3.median(group, (d) => d.yield),
(d) => d.variety
)
.sort(([, a], [, b]) => d3.ascending(a, b))
.map(([key]) => key)
Insert cell
Insert cell
d3.groupSort(barley, g => d3.median(g, d => d.yield), d => d.variety)
Insert cell
Insert cell
d3.groupSort(barley, g => -d3.median(g, d => d.yield), d => d.variety)
Insert cell
Insert cell
d3.groupSort(barley, (a, b) => d3.descending(d3.median(a, d => d.yield), d3.median(b, d => d.yield)), d => d.variety)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more