lexicographic order

Ordering sequences the way a dictionary orders words: compare the first elements, and only if they are equal move on to the next.

In more detail

Python compares tuples lexicographically, so sorting by a key that returns (department, -salary) sorts by department and then by salary descending in one call. The same rule lets (priority, task) tuples order a heap by priority.

Related terms

Taught in

References