Skip to content

Instantly share code, notes, and snippets.

@VanDalkvist
Last active August 29, 2015 14:04
Show Gist options
  • Save VanDalkvist/bc6815fa519013d240f2 to your computer and use it in GitHub Desktop.
Save VanDalkvist/bc6815fa519013d240f2 to your computer and use it in GitHub Desktop.
OrderBy angular filter for objects
filter('orderObjectBy', function () {
return function (items, field, reverse) {
var filtered = [];
angular.forEach(items, function (item) {
filtered.push(item);
});
filtered.sort(function (a, b) {
return (a[field] > b[field] ? 1 : -1);
});
if (reverse) filtered.reverse();
return filtered;
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment