d3/d3-collection

sortValues after rollup

yvescavalcanti opened this issue · 2 comments

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.

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.

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