jQuery + Groovy port of text sorter