Matrix RankC( Matrix m )
The return value is a matrix whose elements are the ranks of the corresponding elements of m. The ranks of tied values are assigned arbitrarily.
Matrix m
A character matrix or literal.
This function behaves like the built-in SAS/IML RANK function except that RankC computes the ranks of a character matrix instead of a numeric matrix. The RankC function
can be used to sort a character vector in ASCII order. Note that uppercase letters precede lowercase letters in the ASCII order, so if you want to compare mixed-case strings, you may want to call
rankc( upcase( m ) )
.
m = { "it" "was" "the", "best" "of" "times", "it" "was" "the", "worst" "of" "times" }; r = rankc( m ); print r; a = { B C C A A D B }; sorted = a; sorted[ rankc(a) ] = a; print sorted;