🏠 back to Observable

Sorting error in Plot

I am working on this ensemble notebook (link below) with Plot (very excited about the much shorter and simpler code than d3), and cannot seem to use d3.sort for this particular graph ( Time Span of All (Major) Parties in West Bengal Elections: 1952-2021). I want the political parties to be sorted with the oldest born first, but everything that I have tried have not changed the alphabetical order. I tried using d3.sort, but got error: d3.sort is not a function. Help, please!

West Bengal Elections


in the configuration for y you could set the domain in the order you prefer:

y: {
  axis: null,
  domain: sortedParties
    .sort((a,b) => d3.ascending(a.Start, b.Start))
    .map(d => d.Party_Name)
1 Like

That works! Thanks so very much!

All the best,