Groovy web console

subscribe to the feed Subscribe
to this
Sort Arraylist (via #groovywebconsole)
tweet this snippet Tweet

Sort Arraylist

Published 1 year ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.transform.ToString

class Person {                       
    String name                      
    Integer age

    Person(name, age) {          = name
        this.age = age

def list = [new Person("Jim", 23), new Person("Tom", 40), new Person("Andrew", 40)]
list.sort{ }