JavaScript: Sorting and filtering data with AngularJS