Skip to content

Glossary: Data Structures and Algorithms in JavaScript

Comparator

Also written: compare function, comparison function

A function given to sort that receives two items and returns a negative number, 0 or a positive number to say which goes first. It must return a number, not true or false.

Where the book teaches it

Related terms

Stable sortArrow function