Skip to content
This repository has been archived by the owner on Nov 11, 2018. It is now read-only.

sortValues after rollup #15

Closed
yvescavalcanti opened this issue Jun 21, 2017 · 2 comments
Closed

sortValues after rollup #15

yvescavalcanti opened this issue Jun 21, 2017 · 2 comments

Comments

@yvescavalcanti
Copy link

I tried to call sortValues after rollup and it didn't work. Looking at the code it seems to me that is not possible in the way it was implemented, i think that it would be good, so we could group some objects and then summarize some values with rollup by group and order the groups by this value. I know it could be done with Array.sort, but anyway, i think that would be nice to do it with sortValues.

@mbostock
Copy link
Member

There is no guarantee that the rollup function returns an array, so it does not make sense to sort the return value of the rollup function.

However, it would be reasonable if nest.sortValues applied to the leaf values before the rollup function is called, even though in many cases (such as computing the sum of leaf values), it is not necessary to sort the input to the rollup function. Currently nest.sortValues is ignored when nest.rollup is used, but I think it makes sense to change it to sort the leaf entries before the rollup function is called.

@yvescavalcanti
Copy link
Author

Ok, i see your point. Thanks for the quick aswer.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants