Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Lexicographic order
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Numeral systems and dates== The lexicographical order is used not only in dictionaries, but also commonly for numbers and dates. One of the drawbacks of the [[Roman numeral system]] is that it is not always immediately obvious which of two numbers is the smaller. On the other hand, with the [[positional notation]] of the [[Hindu–Arabic numeral system]], comparing numbers is easy, because the natural order on [[natural number]]s is the same as the variant [[shortlex order|shortlex]] of the lexicographic order. In fact, with positional notation, a natural number is represented by a sequence of [[numerical digit]]s, and a natural number is larger than another one if either it has more digits (ignoring leading zeroes) or the number of digits is the same and the first (most significant) digit which differs is larger. For [[real number]]s written in [[decimal notation]], a slightly different variant of the lexicographical order is used: the parts on the left of the decimal point are compared as before; if they are equal, the parts at the right of the decimal point are compared with the lexicographical order. The padding 'blank' in this context is a trailing "0" digit. When negative numbers are also considered, one has to reverse the order for comparing negative numbers. This is not usually a problem for humans, but it may be for [[computer]]s (testing the sign takes some time). This is one of the reasons for adopting [[two's complement]] representation for representing [[signed integer]]s in computers. Another example of a non-dictionary use of lexicographical ordering appears in the [[ISO 8601]] standard for dates, which expresses a date as YYYY-MM-DD. This formatting scheme has the advantage that the lexicographical order on sequences of characters that represent dates coincides with the [[chronological order]]: an earlier CE date is smaller in the lexicographical order than a later date up to year 9999. This date ordering makes [[sorting algorithm|computerized sorting]] of dates easier by avoiding the need for a separate sorting algorithm.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)