Mix the letters of the string in alphabetical order in matlab

I have an array of row cells in matlab. I want to sort the letters in each line in alphabetical order. How can i do this?

For example, if I have ['dcb','aetk','acb'}], I want it to be: ['bcd','aekt','abc'].

0
source share
1 answer

A convenient helper here cellfun, with the right option for displaying non-scalar data - we tell him to start sortalternately for each element of the cell array:

>> a = {'dcb' 'aetk' 'acb'}
a =
{
  [1,1] = dcb
  [1,2] = aetk
  [1,3] = acb
}

>> b = cellfun(@sort, a, 'UniformOutput', false);
b =
{
  [1,1] = bcd
  [1,2] = aekt
  [1,3] = abc
}
+3
source

Source: https://habr.com/ru/post/1530859/


All Articles