Created
December 5, 2016 12:25
-
-
Save anonymous/4eec3ea97b000bda3ba2b2486af66bb4 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/wesisamuzu
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var data = [ | |
{ count: 'phone', year: '1956' }, | |
{ count: 'phone', year: '1971' }, | |
{ count: 'text', year: '1989' }, | |
{ count: '33', year: '1932' }, | |
{ count: '33', year: '1912' }, | |
{ count: 'text', year: '1954' }, | |
{ count: 'phone', year: '1920' }, | |
{ count: '33', year: '3444' } | |
]; | |
data.sort(function(a,b){ | |
return a['count']<b['count']?-1:(a['count']>b['count']?1:(a['year']<b['year']?-1:1)); | |
}); | |
var i; | |
for (i = 0; i < data.length; i++) { | |
document.write("<p>count:" + data[i].count + | |
" year:" + data[i].year + "</p>"); | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var data = [ | |
{ count: 'phone', year: '1956' }, | |
{ count: 'phone', year: '1971' }, | |
{ count: 'text', year: '1989' }, | |
{ count: '33', year: '1932' }, | |
{ count: '33', year: '1912' }, | |
{ count: 'text', year: '1954' }, | |
{ count: 'phone', year: '1920' }, | |
{ count: '33', year: '3444' } | |
]; | |
data.sort(function(a,b){ | |
return a['count']<b['count']?-1:(a['count']>b['count']?1:(a['year']<b['year']?-1:1)); | |
}); | |
var i; | |
for (i = 0; i < data.length; i++) { | |
document.write("<p>count:" + data[i].count + | |
" year:" + data[i].year + "</p>"); | |
} | |
</script></body> | |
</html> |
This file contains hidden or 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: 'phone', year: '1956' }, | |
{ count: 'phone', year: '1971' }, | |
{ count: 'text', year: '1989' }, | |
{ count: '33', year: '1932' }, | |
{ count: '33', year: '1912' }, | |
{ count: 'text', year: '1954' }, | |
{ count: 'phone', year: '1920' }, | |
{ count: '33', year: '3444' } | |
]; | |
data.sort(function(a,b){ | |
return a['count']<b['count']?-1:(a['count']>b['count']?1:(a['year']<b['year']?-1:1)); | |
}); | |
var i; | |
for (i = 0; i < data.length; i++) { | |
document.write("<p>count:" + data[i].count + | |
" year:" + data[i].year + "</p>"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment