Pasting elements of two vectors alphabetically

slightly redundant because it sorts twice, but vectorised,

paste(pmin(a,b), pmax(a,b))

Edit: alternative with ifelse,

ifelse(a < b, paste(a, b), paste(b, a))

Leave a Comment