Skip to content

Instantly share code, notes, and snippets.

@tarunbehal
Created February 12, 2017 18:25
Show Gist options
  • Save tarunbehal/61d41c7e8cb5cdee28a54bddde7046ff to your computer and use it in GitHub Desktop.
Save tarunbehal/61d41c7e8cb5cdee28a54bddde7046ff to your computer and use it in GitHub Desktop.
var ageCompare = function(a,b) {
if (a["age"] < b["age"])
return -1;
if (a["age"] > b["age"])
return 1;
return 0;
}
var data = [{name:"a", age: 3}, {name:"b", age: 13}, {name:"c", age: 2}]
data.sort(ageCompare)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment