tablesort <- function(x, ordering="lexicographic", column=1, reverse=false) { # Implementation } # Usage is e.g. tablesort(mytable, column=3)