Sort by two values prioritizing on one of them

Posted by Dojie on Stack Overflow See other posts from Stack Overflow or by Dojie
Published on 2011-01-02T01:50:25Z Indexed on 2011/01/02 1:53 UTC
Read the original article Hit count: 471

Filed under:
|

How would I sort this data by count and year values in ascending order prioritizing on the count value?

//sort this
var data = [
    { count: '12', year: '1956' },
    { count: '1', year: '1971' },
    { count: '33', year: '1989' },
    { count: '33', year: '1988' }
];
//to get this
var data = [
    { count: '1', year: '1971' },
    { count: '12', year: '1956' },
    { count: '33', year: '1988' },
    { count: '33', year: '1989' },
];

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery