mattiash / angular-tablesort

Sort angularjs tables easily
MIT License
184 stars 66 forks source link

Fixed custom comparison not behaving as Array.prototype.sort compareFunction #103

Closed lackovic closed 6 years ago

lackovic commented 6 years ago

The return value of the compareFunction described in MDN can be less than 0 or greater than 0, it does not necessary have to be exactly -1 or 1.

This is consistent with the behavior of the comparing functions of many other programming languages, and allows returning simply the difference a - b when the comparing elements are numbers.

See also this discussion on stackoverflow.