Custom orderBy funcition

0

I need to create a function to make a% custom% in a ordeBy , but I can not think logic that I should use to perform the sort.

The requirement of sorting the list is as follows:

  

Resources must be displayed in ascending order of the date of   presentation. Challenges must be displayed below the appeal   associated in ascending order of the date of presentation.

Here is an example array, where the association between Resources and Challenges is given by the Number field:

[{
'numero': '1',
'dataApresentacao': '2016-01-26T00:00:00-02:00',
'tipo': 'RECURSO'
}, {
'numero': '2',
'dataApresentacao': '2016-01-26T00:00:00-02:00',
'tipo': 'RECURSO'
}, {
'numero': '3',
'dataApresentacao': '2016-01-28T00:00:00-02:00',
'tipo': 'RECURSO'
}, {
'numero': '1',<br>
'dataApresentacao': '2016-01-28T00:00:00-02:00',
'tipo': 'IMPUGNACAO'
}, {
'numero': '4',
'dataApresentacao': '2016-01-27T00:00:00-02:00',
'tipo': 'RECURSO'
}, {
'numero': '1',
'dataApresentacao': '2016-01-29T00:00:00-02:00',
'tipo': 'IMPUGNACAO'
}, {
'numero': '2',
'dataApresentacao': '2016-01-29T00:00:00-02:00',
'tipo': 'IMPUGNACAO'
}]

Any ideas?

    
asked by anonymous 31.01.2016 / 03:01

1 answer

0

The answer is: you do not need a custom%%.

The orderBy accepts more than one field to be sorted, whether it is reverse or not.

Example:

<div ng-repeat="dados in listaArray | orderBy:['primeiro','segundo']"> </div>

For your method, you can use something similar:

<div ng-repeat="dados in listaArray | orderBy:['dataApresentacao','numero']"> </div>

Remember that to reverse the order, simply add the negative sign to the field name, eg: orderBy

    
31.01.2016 / 11:06