EDIT: As noted by kennytm below and after investigating myself, according to the ECMA spec, when two objects are determined to be equal in a custom sort, JavaScript is
May be you know it already but you can use an array to sort on multiple columns and avoid this bug:
var customSort = function(a,b) { return [a.a, a.b] > [b.a, b.b] ? 1:-1; }