Skip to content

Instantly share code, notes, and snippets.

@jhinrichsen
Last active August 3, 2016 07:23
Show Gist options
  • Save jhinrichsen/d32a3e40c7c625fbef8964effa42e112 to your computer and use it in GitHub Desktop.
Save jhinrichsen/d32a3e40c7c625fbef8964effa42e112 to your computer and use it in GitHub Desktop.
// Sort by multiple keys
Collection.metaClass.sort = { Closure... closures ->
delegate.sort(false) { a, b ->
closures.findResult { c -> c(a) <=> c(b) ?: null }
}
}
List threads = Thread.getThreads()
println "${threads.size()}: Threads:"
threads.sort({it.threadGroup.name}, {it.name}).each { println "${it.threadGroup.name}: ${it.name.take(80)}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment