Groovy web console

subscribe to the feed Subscribe
to this


Published 2 months ago by Ricky Lim with tags sort
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
List importantPeople = ["guido", "bart", "bill", "homer", "marge", "mark"]

// Order by size in desc and if size is equal, order by natural ordering in asc
importantPeople.sort { s1, s2 -> 
    s2.size() <=> s1.size() ?: s1 <=> s2