JSFiddle - React, Tailwind, and code Playground
JavaScript
$.ajax({
url: "https://dl.dropboxusercontent.com/s/3v7ya481187k8gf/a.json?dl=0",
}).done(function(data) {
var arr;
// alert('hello')
//console.log(JSON.parse(data)); //$( this ).addClass( "done" );
arr=JSON.parse(data);
arr.sort(sort_by("akritiv__Promise_Date__c", true, ''));
log(arr);
});
function log(arr){
var t = document.getElementById('t');
t.innerHTML = arr[7].akritiv__Promise_Date__c + " | " + arr[10].akritiv__Promise_Date__c + " | " + arr[67].akritiv__Promise_Date__c + " | " + arr[69].akritiv__Promise_Date__c;
}
function sort_by(field, reverse, primer) {
var key = primer ?
function (x) {
return primer(x[field])
} :
function (x) {
return x[field]
};
reverse = !reverse ? 1 : -1;
return function (a, b) {
a = new Date(key(a))=='Invalid Date'?0:new Date(key(a));
b = new Date(key(b))=='Invalid Date'?0:new Date(key(b));
return reverse * (a-b);
}
}