I have an array of arrays, each array within the array is set up like this
[1, firstname, lastname, 22]
I have a total of 12 of these, I am trying to sort the arrays by the 4th element of each array in descending order but nothing I have tried has worked, namely I have been trying to do array.sort with a comparison function and having look at the 4th element in each array but cant get it to work. Here is what I currently have:
function sortArray (a, b){
return a-b;
}
for (var k = 0; k<employeeArray.length; k++){
var j = k-1;
employeeArray.sort(sortArray([k][3],[j][3]));
}
What I was expecting was for the function to sort the arrays by the 4th element but it keeps throwing up Uncaught Type errors.