Hesitant to post this as the answer as I'm admittedly just taking an educated guess but according to MDN, the browser-compatibility for Array.sort
is listed as ECMAScript5 and "yes" for everything (as opposed to listing actual version numbers) - leaving a test for actual support more or less redundant.
The variable name is probably a little bit miss-leading though because if you actually follow what it's doing, the function that is passed to sort
is just returning 0
; typically you might return 1
or -1
depending on your comparison conditions in order to manipulate the order of the array - so by doing this the expected result is that the order of the array remains unchanged.
The return statement is just a chain of boolean checks as to whether the array is still in the same order as it was initially. Arguably then this supportsSort
flag is there to check whether or not the browser/Javascript's implementation of the sort function is in fact a stable algorithm.