Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. var data = [
  2. { count: 'phone', year: '1956' },
  3. { count: 'phone', year: '1971' },
  4. { count: 'text', year: '1989' },
  5. { count: '33', year: '1932' },
  6. { count: '33', year: '1912' },
  7. { count: 'text', year: '1954' },
  8. { count: 'phone', year: '1920' },
  9. { count: '33', year: '3444' }
  10. ];
  11. data.sort(function(a,b){
  12. return a['count']<b['count']?-1:(a['count']>b['count']?1:(a['year']<b['year']?-1:1));
  13. });
  14. var i;
  15. for (i = 0; i < data.length; i++) {
  16. document.write("<p>count:" + data[i].count +
  17. " year:" + data[i].year + "</p>");
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement