Closed SomeshThakur closed 4 years ago
Wow! I never came across this issue. I had a perception that this kind of comparator would work on any simple sorting function. I am pushing a fix which uses ternary operator. :)
@SomeshThakur Thanks so much for your contribution!
Это не правильно. Это не сортируется должным образом. Вы можете проверить это вручную, чтобы подтвердить.
I checked it.
a = 1;
1
b = 2;
2
a > b ? 1 : a === b ? 0 : -1;
-1
a = 2;
2
a > b ? 1 : a === b ? 0 : -1;
0
a = 3;
3
a > b ? 1 : a === b ? 0 : -1;
1
It looks good
We can write it in a more simpler way than the existing code.