d3-grid icon indicating copy to clipboard operation
d3-grid copied to clipboard

Add .sort()

Open jstcki opened this issue 12 years ago • 3 comments

jstcki avatar May 31 '13 14:05 jstcki

And boom, it'll be Isotope for d3. :)

grossbart avatar Jun 01 '13 20:06 grossbart

I'm working on a project where I am basically doing this, any interest in a PR to try and integrate underscore's _.sortBy (will just pull it out)?

I'm imagining something like

data = [
{
  name: 'one',
  id: 1,
  value: 5
},
{
  name: 'two',
  id: 2,
  value: 3
},
{
  name: 'three',
  id: 3,
  value: 1
}
]

  pointGrid = d3.layout.grid()
    .points()
    .size([width-100,height-100])
    .data(data)
    .sortBy(function(d){
      return -d.id
    })

  pointGrid.sortBy('value')

and then update/append/remove normally.

ejfox avatar Jul 27 '16 16:07 ejfox

Wow, what a blast from the past, this issue is three years old! 😄

Does this library even need this feature? Isn't it easier to just sort the data (using d3.ascending, underscore, whatever you like …) before passing it into the layout function? See http://bl.ocks.org/herrstucki/5694697

jstcki avatar Jul 28 '16 07:07 jstcki