[#BloombergLP-bslalg-RangeCompare-lexicographical-07]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslalg.adoc[bslalg]::xref:BloombergLP/bslalg/RangeCompare.adoc[RangeCompare]::lexicographical
:relfileprefix: ../../../
:mrdocs:

Compare two ranges in lexicographical order&period;

== Synopsis

Declared in `&lt;bslalg&lowbar;rangecompare&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class INPUT&lowbar;ITER&gt;
static
int
lexicographical(
    INPUT&lowbar;ITER start1,
    INPUT&lowbar;ITER end1,
    INPUT&lowbar;ITER start2,
    INPUT&lowbar;ITER end2);
----

== Description

Compare each element in the range beginning at the specified `start1` position and ending immediately before the specified `end1` position, to the corresponding element in the range beginning at the specified `start2` position and ending immediately before the specified `end2` position&period; Optionally specify the length of each range, `length1` and `length2`&period; Return a negative value if the first range compares lexicographically less than the second range, 0 if they are the same length and compare lexicographically equal, and a positive value if the first range compares lexicographically greater than the second range&period; The behavior is undefined unless `length1` is either unspecified or equals the length of the range `&lsqb;start1, end1)&rsqb;`, and `length2` is either unspecified or equals the length of the range `&lsqb;start2, end2)&rsqb;`&period; Note that this implementation uses `std&colon;&colon;memcmp` for unsigned character comparisons, `std&colon;&colon;wmemcmp` for wide character comparisons, and `operator&lt;` for all other types&period;

== Return Value

a negative value if the first range is less, 0 if equal, and a positive value if the first range is greater

== Parameters

[cols="1,4"]
|===
| Name| Description
| *start1*
| beginning of the first range
| *end1*
| end of the first range (one past the last element)
| *start2*
| beginning of the second range
| *end2*
| end of the second range (one past the last element)
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
