It sometimes happens that one needs a three-way comparison function (return negative, zero or positive based on less than, equal or greater than). To be sure, this is only half a dozen lines of code, but it's half a dozen lines that seems like it shouldn't need to be repeated in every program.
Is there such a function built-in, or in some recommended npm package?
via rwallace
No comments:
Post a Comment