RosettaCodeData/Task/Optional-parameters/Groovy/optional-parameters-1.groovy
2023-07-01 13:44:08 -04:00

3 lines
205 B
Groovy

def orderedSort(Collection table, column = 0, reverse = false, ordering = {x, y -> x <=> y } as Comparator) {
table.sort(false) { x, y -> (reverse ? -1 : 1) * ordering.compare(x[column], y[column])}
}