The lexicographical_compare() functions compare each element in the range [start1, finish1) to the corresponding element in the range [start2, finish2) using iterators i and j.

The first version of the algorithm uses operator<() as the default comparison operator. It immediately returns true if it encounters any pair in which *i is less than *j, and immediately returns false if *j is less than *i. If the algorithm reaches the end of the first sequence before reaching the end of the second sequence, it also returns true.

The second version of the function takes an argument comp that defines a comparison function that is used in place of the default operator<().

The lexicographical_compare() functions can be used with all the data types included in the standard library.