So I have this code -
console.log(data);
data = data.sort(function(d1,d2){
var a1= d1["date"].split('/'), b1=d2["date"].split('/');
if(a1[2]==b1[2]){
return (a1[0]==b1[0])? a1[1]-b1[1]: a1[0]-b1[0];
}
return a1[2]-b1[2];
});
console.log("DATA");
console.log(data);
with this data -
[
{ "date": "2/7/2012", "quantity: " 4"},
{ "date": "2/4/2012", "quantity: "5"},
{ "date": "2/3/2012", "quantity: "10"},
{ "date": "2/5/2012", "quantity" : "12"},
{ "date": "2/6/2012", "quantity" : "10"}
]
The two console logs show the data in the same way, or the sorting has no effect. The data coming out of the sort function is in the same order as the data going in.
Why?
quantity.quantityproperties.