Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: dummy

...

Two special comparison operators are useful with the sort() operator: <=> and cmp. These operators return -1 if the first operand is less than the second, 0, if they're equal, and 1 if the first operand is greater than the second. Unlike the <=> operator, cmp treats its arguments like is used with strings. Either works if

Code Block
languagejavascript
themeConfluence
x = 5; 
y = 6;
x <=> y // returns -1
x <=> x // returns 0
y <=> x // returns 1
p = "aab";
q = "abb";
a cmp b // returns -1
a cmp a // returns 0
b cmp a // returns 1

...