Sort data frame

sort_df(df, by, decreasing = FALSE)

Arguments

df

data frame

by

column to sort by

decreasing

logical. Should sorting be decreasing?

Value

A sorted data frame

Examples


df <- data.frame(a = c(2, 4, 3), b = c(3, 5, 1))
misc::sort_df(df, "a")
#>   a b
#> 1 2 3
#> 3 3 1
#> 2 4 5
misc::sort_df(df, "b", decreasing = TRUE)
#>   a b
#> 2 4 5
#> 1 2 3
#> 3 3 1