I"m trying to do a custom sort in this order: 1) Numeric digit furthest right; 2) Alphabetical second furthest to the right; 3) Alphabetical the rest of the string beginning with the first character;
The example code I'm using is an array that follows: /myArray <- c('AFP9','AFR9','TLQP7','AFS9','AFR8','AFP8','AFS7','TLQS8')/ The output I desire is: />myArray [1] "AFS7" "AFP8" "AFR8" "AFP9" "AFR9" "AFS9" "TLQP7" TLQS8" / What I'm thinking is writing a function that will order it by analyzing it from right to left. Ideally there would be a way to look at the individual strings like the formula in Excel "=RIGHT(cell, 1)" and drop the furthest right then do the same thing to the next character. I've been looking into custom sort for R and haven't found much. Any idea what this function would look like? Possibly a while loop? Each string would have a length of at least 3, possibly longer. Thank you in advance. -- View this message in context: http://r.789695.n4.nabble.com/Custom-Sort-Character-and-Numeric-tp3909058p3909058.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.