Groovy web console

subscribe to the feed Subscribe
to this
site
Collections (via #groovywebconsole)
tweet this snippet Tweet
this
script

Collections

Published 2 months ago by mbjl
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class Foo {
    Integer id
    String name
}

def fooList = []

foo1 = new Foo(id:5, name:"Test 5")
fooList << foo1
fooList << foo1

foo2 = new Foo(id:2, name:"Test 1")
fooList << foo2

foo6 = new Foo(id:6, name:"Test 5")
fooList << foo6 
fooList << foo6 

fooList.sort{ it.id }.groupBy { it.id }