mySelection.sort( comparator ) in D3.js

Sort the order of elements in the selection (and DOM) according to custom criteria.


comparator Function This function is passed two data elements a and b to compare, and must return either a negative number, positive number, or zero. If negative, then a should be before b; if positive, then a should be after b; if zero, a and b are considered equal and the order is arbitrary.
Return Type


For more details see

See Also