JSFiddle - React, Tailwind, and code Playground
JavaScript
//sort this
var data = [
{ count: '12', year: '1956' },
{ count: '1', year: '1971' },
{ count: '33', year: '1989' },
{ count: '33', year: '1988' }
];
data.sort(function(a, b) {
// Sort by count
var dCount = a.count - b.count;
if(dCount) return dCount;
// If there is a tie, sort by year
var dYear = a.year - b.year;
return dYear;
});
alert(JSON.stringify(data));