Common Questions (original) (raw)

order groupBy result

Question: how to use orderBy with groupBy ?
See: issue #26

$scope.groups = [ { category: 'alpha', id: 2 }, { category: 'beta', id: 3 }, { category: 'gamma', id: 0 }, { category: 'alpha', id: 4 }, { category: 'beta', id: 5 }, { category: 'gamma', id: 1 } ]; // retrieves the min 'id' of a collection, used for the group ordering. //you can use lodash instead. e.g: _.min(arr, 'id') $scope.min = function(arr) { return $filter('min') ($filter('map')(arr, 'id')); }