# Plot: Sorting Groups Question

**URL:** <https://talk.observablehq.com/t/plot-sorting-groups-question/6554>\
**Category:** Help\
**Created:** [May 15, 2022, 2:45am UTC](https://talk.observablehq.com/t/plot-sorting-groups-question/6554 "2022-05-15T02:45:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thorgch](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/thorgch/32/6417_2.png) [@thorgch](https://talk.observablehq.com/u/thorgch)\
**Post date:** [May 15, 2022, 2:45am UTC](https://talk.observablehq.com/t/plot-sorting-groups-question/6554/1 "2022-05-15T02:45:13Z")

</div>

I’ve got a sorting problem that I’d like some help on. I’ve included a link to an example notebook.

> **[Grouping and Sorting](https://observablehq.com/d/5240c05ee578ad93)**

What I’d like to do is sort the categories (the _package_ property in the dataset) by the _changes_ property in the dataset, and not the property that was encoded as the **x** channel. This is all for plotting some metrics from a formatted git repo log. I’ve figured out how to plot the addition and removal metrics for each package, but I’m not sure how to sort with the property I want.

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [May 15, 2022, 11:36am UTC](https://talk.observablehq.com/t/plot-sorting-groups-question/6554/2 "2022-05-15T11:36:14Z")

</div>

we have an issue open for that feature [sort by channel not used to visualize? · Issue #867 · observablehq/plot · GitHub](https://github.com/observablehq/plot/issues/867)

currently the best way to do this is to make the domain explicit in the y scale definition, for example with d3.groupSort:

> y: {domain: d3.groupSort(data, v =\> d3.sum(v, d =\> d.changes), d =\> d.package).reverse()},

---

<div class="post-metadata">

**Author:** ![thorgch](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/thorgch/32/6417_2.png) [@thorgch](https://talk.observablehq.com/u/thorgch)\
**Post date:** [May 15, 2022, 3:53pm UTC](https://talk.observablehq.com/t/plot-sorting-groups-question/6554/3 "2022-05-15T15:53:39Z")

</div>

Thanks, @Fil. This workaround did what I needed. I’ve also republished the example above to include your suggestion in case anyone comes across this same problem in the future.
