Skip to content

Instantly share code, notes, and snippets.

@nobeans
Created March 31, 2018 05:12
Show Gist options
  • Save nobeans/c52a669a7eacf680b43f93af5b491479 to your computer and use it in GitHub Desktop.
Save nobeans/c52a669a7eacf680b43f93af5b491479 to your computer and use it in GitHub Desktop.
intがoverflowする時にソート順序が入れ替わる
int i = 2147483647
def l = [a:i-1, b:i, c:i+1]
assert l == [a:2147483646, b:2147483647, c:-2147483648]
assert l.sort { it.value }*.key == ['c', 'a', 'b']
assert l.collectEntries { [it.key, "lock-" + it.value] }.sort { it.value }*.key == ['c', 'a', 'b']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment