Trying to implement code from Scott Murray's book "Interactive Data Visualization for the Web" to create versatile bar graphs. Though the code successfully generates and updates graphs, it seems that the sorting functionality is not functioning as expected. Despite confirming that the sort function works by adding a click event to trigger it when individual bars are clicked, the overall sorting functionality remains elusive.
To view the issue in action, check out the JSFiddle link provided - http://jsfiddle.net/kiniadit/k812fo53/3/
Specifically, the problematic code segment can be found in lines 74-77:
else if(btnClass == "sort"){
sortBars();
sortLabels();
}