func table_sort(table, ordering: '<=>', column: 0, reverse: false) { if (reverse) { table.sort {|a,b| b[column].$ordering(a[column])} } else { table.sort {|a,b| a[column].$ordering(b[column])} } } # Quick example: var table = [ ["Ottowa", "Canada"], ["Washington", "USA"], ["Mexico City", "Mexico"], ]; say table_sort(table, column: 1);