str(TF)
ans = 1x3 string array
"Sanchez" "de Ponte" "Nash"
Sort String Arrays
You can sort string arrays. MATLAB® stores characters as Unicode® using the UTF-16
character encoding scheme. Character and string arrays are sorted according to the
UTF-16 code point order. For the characters that are also the ASCII characters, this order
means that uppercase letters come before lowercase letters. Digits and some punctuation
also come before letters.
Sort the string array str.
sort(str)
ans = 1x5 string array
"Crosby" "Jones" "Nash" "Sanchez" "de Ponte"
Sort a 2-by-3 string array. The sort function sorts the elements in each column
separately.
sort(str2)
ans = 2x3 string array
"Jupiter" "Mars" "Apollo"
"Mercury" "Saturn" "Neptune"
To sort the elements in each row, sort str2 along the second dimension.
sort(str2,2)
ans = 2x3 string array
"Apollo" "Mars" "Mercury"
"Jupiter" "Neptune" "Saturn"
Compare Character Vectors
You can compare character vectors and cell arrays of character vectors to each other. Use
the strcmp function to compare two character vectors, or strncmp to compare the first
N characters. You also can use strcmpi and strncmpi for case-insensitive comparisons.
6 Characters and Strings