Glossary term

What is comparator? Meaning for developers

The function you give to sort: (a, b) => negative if a goes first, positive if b goes first, 0 if equal. For numbers, use (a, b) => a - b.

Learn it properly · DSALesson 18: Quick Sort, and When to Just Use .sort()Partitioning around a pivot, quickselect, and sorting numbers and objects correctly in JavaScript.

All DSA terms

Related terms

← All glossary terms, A to Z