This example will show how to find the shortest or minimum length string contained within a list using groovy. In snippet below we will reference Katie Perry song titles where we will use a closure to create a Comparator to sort by the length of a string. The <=>
operator or spaceship operator will return -1 if left is smaller 0 if == to right or 1 if greater than the right and in this instance will sort the collection by smallest to greatest. A comparable example we demonstrate how to get the smallest length string in a collection using java, java 8 and guava.