The
d3.descending() function in D3.js is a comparator function for the reverse natural order and returns -1 if it takes two parameters in descending order, 1 if it takes two parameters in ascending order and 0 if it takes two equal parameters.
Syntax:
d3.descending(a, b)
Parameters: This function accepts parameters
a, b which are any two value.
Return Value: It returns -1 if it takes two parameters in descending order (1st parameter is greater than 2nd parameter) or 1 if it takes two parameters in ascending order (2nd parameter is greater than 1st parameter) or 0 if it takes two equal parameters.
Below programs illustrate the d3.descending() function in D3.js.
Example 1:
Output:
-1
1
0
Example 2: