user3206082
user3206082

Reputation: 431

sort a dimension in crossfilter - d3

This is the fiddle.

I'm trying to show the show the top 100 rows in descending order of a column.

Suppose I have a dimension, how do it sort it?

Came across this. But couldn't fine anythign useful.

Help me in sorting the data in descending order on the value column.

Upvotes: 1

Views: 4107

Answers (1)

Matt Traynham
Matt Traynham

Reputation: 205

When you create a dimension, it will sort the data for you using a dual-pivot quick sort algorithm. Calling dimension.top(n) will return you the top documents back. Vice versa, calling dimension.bottom(n), will return you the bottom most documents. It will be the natural sort order, so if you want all the documents back sorted descending, use:

var sortedDescending = dimension.top(Number.POSITIVE_INFINITY);

Upvotes: 1

Related Questions