Skip to content

Instantly share code, notes, and snippets.

@meeDamian
Created October 2, 2012 08:35
Show Gist options
  • Save meeDamian/3817375 to your computer and use it in GitHub Desktop.
Save meeDamian/3817375 to your computer and use it in GitHub Desktop.
[ JS | LIBS ] Re-Sorting list on properties
// LIBS: returns proper sorting function
function sort_by( prop ) {
return function(a,b) {
return a[prop] - b[prop];
}
}
// USAGE: resort list on eid property
list.sort( sort_by('eid') );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment