After working on this question for quite a while, I’ve realized that I don’t fully understand how uksort works internally and can’t find any documentation to that effect.
What order are the values processed, and does further processing for a value stop when you return an integer value for the current comparison?
The order the values are processed in is up to the interpreter’s sorting algorithm. The upshot is that you shouldn’t worry about it; the end result will be the same no matter what order they’re processed in (if you sort of deck of cards it will end up in the same order whether or not you shuffled it beforehand as long as
2 < 3andJ < Qand so on).In all but the most naïve sort algorithms a value will be visited (“processed”) several times before arriving in its final place in the result array. When you
returnin the callback you supply touksortthat is not necessarily the last time the callback will be called for those two values.