Basically I want to build a function which sorts objects in an array by one of the object\'s properties/member variables. I am preeeety sure that the comparator function is wher
The compare function needs two arguments: the first and the second element it should compare. So your compareFN should look like this:
function compareFN(taskA, taskB) {
return taskA.priority - taskB.priority;
}
Edit: As NPE said, it is supposed to perform a three-way comparison, so a simple a < b
is not so a great idea here.