0

I'm sorting an array of objects by the name property which is the same for all items.
However, the array's first 3 items are never the same, it's like they take turns to be first item (haha).

I'm using ngRepeat to display the array in a table.

Any idea what the issue might be?
Could it be a problem of digest timing vs. sort timing?

Here's a Plnkr, click the top button to see what I mean:
http://plnkr.co/edit/6CXxDEHJksPBLiMrpP3r?p=preview

Console outputs the result of the sort function, and it's always 0, meaning the compared items have the same value.

Francisc
  • 77,430
  • 63
  • 180
  • 276
  • 2
    See the second sentence in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FArray%2Fsort. Then read http://stackoverflow.com/questions/1427608/fast-stable-sorting-algorithm-implementation-in-javascript – JB Nizet Jan 28 '14 at 13:31
  • Ah yes, thank you for that. Could you post it as an answer so I can accept it. – Francisc Jan 28 '14 at 14:08

0 Answers0