Created
July 31, 2017 08:02
-
-
Save xexi/28e447fea2f92ca67f25d397a8bd698d to your computer and use it in GitHub Desktop.
sort by two values prioritizing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = [ | |
{ count: '12', year: '1956' }, | |
{ count: '1', year: '1971' }, | |
{ count: '33', year: '1989' }, | |
{ count: '33', year: '1988' } | |
]; | |
data.sort(function (x, y) { return x.count - y.count || x.year - y.year; }); | |
console.log(data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment