title: How to generate all permutations of an array in sorted order?
body: <p>I have an array, and the user can insert a string.</p>
  
  <p>And I have this code:</p>
  
  <pre><code>int main(){
    char anagrama[13];
    cin &gt;&gt; anagrama;
    for(int j = 0; j &lt; strlen(anagrama); j++){
      cout &lt;&lt; anagrama[j];
      for(int k = 0; k &lt; strlen(anagrama); k++){
        if(j != k)
          cout &lt;&lt; anagrama[k];
      }
      cout &lt;&lt; endl;
    }
  }
  </code></pre>
  
  <p>The problem is that I need all <strong>permutations</strong> of the string in <strong>sorted</strong> order.</p>
  
  <p>For example if the user write: <code>abc</code>, the output must to be:</p>
  
  <pre><code>abc
  acb
  bac
  bca
  cab
  cba
  </code></pre>
  
  <p>and my code doesn't show all permutations, and not sorted</p>
  
  <p>Can you help me?</p>
  
  <p>I need do the implementation without a function already implemented.</p>
  
  <p>I think with a recursive function, but I do not know how.</p>
  
  <p>This is an example: 
  <a href="http://www.disfrutalasmatematicas.com/combinatoria/combinaciones-permutaciones-calculadora.html">http://www.disfrutalasmatematicas.com/combinatoria/combinaciones-permutaciones-calculadora.html</a>  without repetition and sorted</p>