Minecraft Wiki
Advertisement
Minecraft Wiki
[view | edit | history | purge]Documentation
Lua logo.png
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

[view | edit | history | purge]The above documentation is transcluded from Template:StringCompare/doc.