How to do an alphnumeric sort in R

Posted by cbare on Stack Overflow See other posts from Stack Overflow or by cbare
Published on 2010-05-06T02:18:48Z Indexed on 2010/05/06 2:28 UTC
Read the original article Hit count: 220

Filed under:

Is there an alphanumeric sort for R?

Say I had a character vector like so:

> seq.names <- c('abc21', 'abc2', 'abc1', 'abc01', 'abc4', 'abc201', '1b', '1a')

I'd like to sort it aphanumerically, so I get back this:

c('1a', '1b', 'abc1', 'abc01', 'abc2', 'abc4', 'abc21', 'abc201')

Does this exist somewhere, or should I start coding? Thanks,

-chris

© Stack Overflow or respective owner

Related posts about r