Groovy web console

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

toSorted

Published 8 months ago by Jonny
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class Item {
   String AuthorMail
   String ChangePackageID
   String UpdateMember
   Boolean highPrio
   String time
   String warnings

   String toString(){
      def ret = []
      ret.add("${AuthorMail}")
      ret.add("Warn: ${warnings}")
      ret.add("Time: ${time}")
      return ret.join("\n\t") + '\n'
   }
}

items = [
new Item(AuthorMail: 'bla1', warnings: '1', time: 1),
new Item(AuthorMail: 'bla2', warnings: '1', time: 10),
new Item(AuthorMail: 'bla3', warnings: '1', time: 2),
new Item(AuthorMail: 'bla4', warnings: '0', time: 5)
]
items = items.toSorted({it -> [it.warnings, it.time] })
for (Item curItem : items) {
println curItem
}