I am having issues on identifying the actually index of the array its being sorted.
My list is a bit messy:
masterList =[];
masterList.push([1,"NY","New York, NY 10036, United States",40.760262,-73.993286,"07/30/2015"]);
masterList.push([2,"Chgo","Chicago, IL, United States",41.878113,-87.629799,"07/06/2015"]);
masterList.push([3,"Japan","Japan",11.1111,-11.1111,"07/22/2015"]);
masterList.push([4,"China","China",22.2222,-22.2222,"07/18/2015"]);
masterList.sort(sortdates());
function sortdates(a,b) {
return function(a, b){
a = Date(a[5]);
console.log(a);
b = Date(b[5]);
return a - b;
};
}
Obviously this isn't working. I want to be able to grab the 6st index on the multidimensional array and sort by that.
I tried looking everywhere.. but I don't have a "key" that ties to my array.. so I can't really use that to point it. Any suggestions?
masterList.sort(sortdates())you have to writemasterList.sort(sortdates). You have to provide a reference to a function, not call the sort-function.