2

I'm currently learning about lexicographical sorting but not much is found for numbers. The example i found is based of What is lexicographical order?

In the example, it i said that

1 10 2

are in lexicographical ordering. The answer stated that "10 comes after 2 in numerical order but 10 comes before 2 in alphabetical order". I would like to know what does "10 comes before 2 in alphabetical order" really mean. Is 10 represented as a character in ASCII or something? I'm really confused.

Would it be something in python where:

ord(10) 
Maxxx
  • 3,688
  • 6
  • 28
  • 55

1 Answers1

0

Yes, lexicographic implies textual. I would fault the typography. When discussing a text string, that is usually made clear by using the literal text string syntax (for some programming language). "10" comes before "2".

There is no text but encoded text.

So that implies a character encoding of a character set. A character set is a mapping between a character and a codepoint (integer). An encoding maps between a codepoint and a sequence of code units for that encoding. A code unit is an integer of a fixed size. When an integer of a fixed size is stored as a sequence of bytes, it has a byte order (unless the size is 1).

Lexicographic could refer to ordering by the sequence of:

  • codepoint values
  • code unit values
  • byte value

For some character sets and encodings, these orders would all be the same. For some of those, the values would all be the same.

(Not sure why you would mention ASCII. You are almost certainly not using a programming environment that uses ASCII natively. You should look that up for your environment to avoid ASCII-splaining. Python 3.)

Tom Blodget
  • 20,260
  • 3
  • 39
  • 72