I have been debugging my JavaScript code for two days and now I found that it works in Firefox.
I uploaded the code into jsFiddle so you can test it there.
It works perfect in Firefox v23 but it doesn't sort in Chromium v28.0.1500.71. I'm using jQuery v1.10.1
I don't know if the error is on the sort() function or maybe in the jQuery library.
Should this be reported as a bug in Chromium?
var data = {
"list": [
{
"title": "a",
"date": "03/08/2010"
},
{
"title": "b",
"date": "31/07/2010",
},
{
"title": "c",
"date": "08/08/2010",
},
{
"title": "d",
"date": "01/08/2010"
},
{
"title": "e",
"date": "11/12/2010"
},
{
"title": "f",
"date": "10/12/2010"
},
{
"title": "g",
"date": "12/12/2010"
},
{
"title": "h",
"date": "14/12/2010"
},
{
"title": "i",
"date": "11/12/2010"
},
{
"title": "j",
"date": "05/08/2010"
},
{
"title": "k",
"date": "03/08/2010"
}
]
};
// Sort
$.each(data, function (key, val) {
val.sort(function(a, b) {
return a.title.toLowerCase() > b.title.toLowerCase();
});
// The object is not sorted here
});
// Print
document.querySelector("pre").textContent =
JSON.stringify(data, null, 4);