So I finally found a sane explanation to my question, which was pretty simple, why this awkward behavior happens, not how it's meant or supposed to be written, or kinda things. I just debugged the source code calls in dev tools withing angular step by step and it turns out to be this:
So it turns out that due to specificity of parsing mechanism in angular, '.' is eventually considered to be in this case a NaN and inside the sorting function of an array the last return v1 < v2 ? -1 : 1;
defaults to false and we get 'return 1' which reverses our array order constantly.
You can yourself try [1,2,3].sort(function(a, b){return 1;})
, the output will be [3,2,1]
.
Bingo.
Upd: in current version of angular there is a correctly thrown error on such behavior:
Error: $parse:syntax : Token '.' not a primary expression at column 1 of the expression [.] starting at [].