Skip to content

Instantly share code, notes, and snippets.

@hpfast
Forked from anonymous/jsbin.EKekatAy.html
Created December 13, 2013 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hpfast/7943111 to your computer and use it in GitHub Desktop.
Save hpfast/7943111 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<ul id="buh"></ul>
</body>
</html>
var array = [
{
attributes:{
name:'Peter',
age:22,
dob:'2020-04-10T08:32:33Z'
}
},
{
attributes:{
name:'Hans',
age:23,
dob:'2010-03-31T08:32:33Z'
}
}
];
function music(a,b){
var ageA = a.attributes.age.toString();
var ageB = b.attributes.age.toString();
var dobA = a.attributes.dob.split(/[\- : T Z]/);
var dobB = b.attributes.dob.split(/[\- : T Z]/);
console.log(dobA);
return dobB[0] - dobA[0];
}
array.sort(music);
for(i=0;i<array.length;i++){
$('#buh').append($('<li>').text(array[i].attributes.name))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment