Advertisement

StringCompare/doc

This is the documentation page. It should be transcluded into the main template page. See Template:Documentation for more information
This template uses Module:StringCompare, a script written in Lua.

Parameters

  • |1=: First string to compare.
  • |2=: Second string to compare.
  • |ci=: Set this to do case-insensitive comparison.
  • |versions=: Set this to do a sort-of-numeric comparison:
    • splits on whitespace and compares tokens alphabetically, except when tokens are all digits/periods, in which case it splits the token on the period and compares the numbers numerically.

Output

  • 0 if the two strings are the same,
  • -1 if the first string sorts before the second,
  • 1 if the first string sorts after the second.

Examples

normal, alphabetic usage

{{StringCompare| abc | aaa }} → 1

{{StringCompare| aaa | aaaa }} → -1

{{StringCompare| 12 | 8 }} → -1

versions

{{StringCompare| 1.12.2 | 1.12.2 }} → 0

{{StringCompare| 1.12.2 | 1.12.11 }} → 1

{{StringCompare| 1.12.2 | 1.12.11 |versions=1}} → -1

{{StringCompare| 1.12.2 | 1.8 |versions=1}} → 1

See also



Community content is available under CC BY-NC-SA 3.0 unless otherwise noted.

The Minecraft Wiki is no longer considered as official by Microsoft and therefore several changes are required to be made, including to the wiki's logo. Please read this announcement for more information.

READ MORE