What would be the proper way to add on a sort as a method chain here?
let data = [
{'country': 'US', 'state': 'DE'},
{'country': 'US', 'state': 'CA'},
{'country': 'US', 'state': 'MI'},
{'country': 'RU', 'state': null}
];
let us_data = data
.filter(elem => elem['country'] === 'US')
.filter(elem => ['CA', 'DE'].includes(elem['state']))
// .sort((a,b) => a['state'] < b['state']) ???
console.log(us_data);
In other words, the correct way to add on the sort in the above (but not in-place?)