Function to sort a column of alphanumeric strings (e.g. c("a1",
"a11", "a2")) in numeric order (e.g. c("a1", "a2", "a11")). It works with
pipes, and you can provide column name or index as argument sort_col
.
Examples
tr_sort_alphanum(
input_df = data.frame(
colA = c("a11", "a1", "b1", "a2"),
colB = c(3, 1, 4, 2)
),
sort_col = "colA"
)
#> colA colB
#> 2 a1 1
#> 4 a2 2
#> 1 a11 3
#> 3 b1 4