title: Matlab function to compare the elements of two strings
body: <p>I want to write a Matlab function that compares the elements of two strings, so that given a single cell array of strings, it will return that single cell array but in alphabetical order eg <code>function({'car','apple','bus'})</code> so I have written a sub-function that compares the elements of two strings against one another and assigns a numerical value:</p>
  
  <pre><code>function [ out ] = comparestrings( a,b )
  
  for k=1:min(length(a),length(b))
  
      if a(1,k)&lt;b(1,k)
         out=1;
         return
      elseif b(1,k)&lt;a(1,k)
          out=0;
          return
      end    
  end
      if length(a)&lt;length(b)        
         out=1;
      else out=0;      
      end   
  end
  </code></pre>
  
  <p>But when I try and run my program in Matlab, it says there is an error in the line</p>
  
  <pre><code>if a(1,k) &lt; b(1,k)
  </code></pre>
  
  <p>I have no clue why this could be?</p>