Skip to content

Instantly share code, notes, and snippets.

@Shipow
Last active December 30, 2015 20:19
Show Gist options
  • Save Shipow/7880369 to your computer and use it in GitHub Desktop.
Save Shipow/7880369 to your computer and use it in GitHub Desktop.
Angular filter orderObjectBy
app.filter('orderObjectBy', function(){
return function(input, attribute) {
if (!angular.isObject(input)) return input;
var array = [];
for(var objectKey in input) {
array.push(input[objectKey]);
}
array.sort(function(a, b){
a = parseInt(a[attribute]);
b = parseInt(b[attribute]);
return a - b;
});
return array;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment