As you can see in this JsFiddle, http://jsfiddle.net/h4FCy/, if you sort a repeater with a function and a "track by", it doesn't sort items. If you remove the "track by", the items are sorted.
The syntax is tricky here. track by
always goes at the end, even after other filters:
item in items | orderBy:'toString()' track by $index
See updated working fiddle: http://jsfiddle.net/VrLBz/1/
I didn't know that, thanks. I thought at first I had a working exemple (with object instead of strings) but it was working by chance.
:+1: i was looking for this
:+1: awesome - thanks
Superb !! track by and order by worked after an hour of googling until i found this. thanks.
please document this in the docs for ng-repeat, i also had to search for a long time before i found this!
@CWSpear thanks!
@CWSpear thanks
I think I might have found one case where track by $index at the end fails to sort. If the filters are being set to a result.
x in (auditEventsFiltered = (auditEvents | orderBy:sortType:sortReverse | statusOutcomeFilter:filters | multiWordFilter:filters)) track by $index
Most helpful comment
The syntax is tricky here.
track by
always goes at the end, even after other filters:See updated working fiddle: http://jsfiddle.net/VrLBz/1/