I want to sort the data according to following conditions:
Sort by
type
with precedence as [state,city,district].-Data with type state should be at first place, then data with city and so on.
Duplicate data should be sort by
score
.-eg : if 3 rows are with type, then sort it by score.
My data object is:
$scope.data = [{
id: 1,
name: 'ABC',
type: 'city',
score: 0.1
}, {
id: 2,
name: 'PQR',
type: 'city',
score: 0.7
}, {
id: 3,
name: 'ABC',
type: 'state',
score: 0.3
});
And template is:
<div ng-repeat="d in data">
<span>{{d.name}}</span>
<span>{{d.type}}</span>
<span>{{d.score}}</span>
</div>
Result should be like this:
ABC state 0.3
PQR city 0.7
ABC city 0.1
Here is the link of plunker.
I want to sort it by multiple fields as well as with a specific precedence.
Any help will be appreciated. Thanks in advance.