Skip to content

Commit

Permalink
Clarify "as normal" -> "lexicographically"
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtriplett committed Aug 28, 2023
1 parent 95eb1e2 commit f06df22
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/doc/style-guide/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ lexicographical.)

For the purposes of the Rust style, to compare two strings for version-sorting:

- Compare the strings by (Unicode) character as normal, finding the index of
the first differing character. (If the two strings do not have the same
length, this may be the end of the shorter string.)
- Compare the strings by (Unicode) character lexicographically, finding the
index of the first differing character. (If the two strings do not have the
same length, this may be the end of the shorter string.)
- For both strings, determine the longest sequence of ASCII digits that either
contains or ends at that index. (If either string doesn't have such a
sequence of ASCII digits, fall back to comparing the strings as normal.)
sequence of ASCII digits, fall back to comparing the strings
lexicographically.)
- Compare the numeric values of the number specified by the sequence of digits.
(Note that an implementation of this algorithm can easily check this without
accumulating copies of the digits or converting to a number: after skipping
Expand Down

0 comments on commit f06df22

Please sign in to comment.