http://pastie.org/private/y97y0idv0s4z3grztqsgw
Here is my Json response, how can i sort this based on DateOfBirth... i mean the result...
http://pastie.org/private/y97y0idv0s4z3grztqsgw
Here is my Json response, how can i sort this based on DateOfBirth... i mean the result...
What kind of date format is: \Date(410225400000-0500)/
????
You will need to parse that into a normal date format to do comparisons.
You seem to be storing time as well?
Easiest is to store either unixtime or juliandate, both sort nicely. But yyyymmdd works fine too. But the string you have does not.
I think it's best to convert the string-value from DateOfBirth to a real date. Given the format of the datestring in your json, this may be a way to do the sorting then:
var sortList = Json.sort( function(a,b) {
var dateA = new Date(Number(a.DateOfBirth.replace(/[^0-9]/g,''))),
dateB = new Date(Number(b.DateOfBirth.replace(/[^0-9]/g,'')));
return dateA < b.dateB;
});
A possible solution is to sort the date using a space-filling-curve. It's a fractal function f(x,y)=z in the euklidean space. Look here: http://lapin-bleu.net/riviera/?p=78