I am trying to understand how the .sort() method works.
My implementation should be very simple, using the method:
.sort(function (a, b) {
});
I want to check whether the element is a member of a certain class. If it is, I want it to be put towards the top. Otherwise, it should go to the bottom. What's the pattern?
The sort is on a path group of states from a geojson projection:
d3.json("./data/states.json", function(us) {
mapSvg.selectAll("path")
.data(us.features)
.enter()
.append("path")
.attr("d", path).attr("class",function(d){return "border2 thestates"})
});
}
I want to bring some of the states to the front if they have a class.