Learn R Programming

quickcode (version 1.0.3)

sort_length: Sort vector by length of its content

Description

Sort the length of the content of a vector

Usage

sort_length(vec, asc = TRUE)

Value

vector of items sorted by length

Arguments

vec

a vector

asc

TRUE or FALSE whether to sort by ascending or descending order

Examples

Run this code
# sort by length of content
x = c("acs","tt","jdssr","h","grab")
sort_length(vec = x) # ascending order of length
sort_length(vec = x, asc = FALSE) # descending order of length


Run the code above in your browser using DataLab