This is testable so don’t guess. Find out. Judging by their names they are numbers, so:
console.log(3 > 1)
I’m guessing that’s not the issue (if there is any at all)
But perhaps there are a couple of things that you need to happen in the code, you could use console.log to get information out of your program
If you’re asking why it seems to work despite an incorrect comparison function, then yes, your comparison function does the right thing in some cases and if only those are used then you’ll end up with a correctly sorted array. It does return a positive value when a is greater than b, and it does return 0 when a is equal to b. Changing the data in the array may give you cases where it comes out sorted incorrectly.