title: order a character array such that all the vowels appear at the last
body: <p>i'm trying to write a program in which a word as a string is provided as an input and i have to rearrange the word such that it just changes the order of the letters in a word by moving
  all the vowels to the end, keeping them in the same order as they appeared in the original word</p>
  
  <pre><code>namespace ConsoleApplication1
  {
      class Program
      {
          static void Main(string[] args)
          {
              string word = "application";
              char[] letters = word.ToCharArray();
              char x = new char { };
              for (int j = 0; j &lt; letters.Length; j++)
              {
                  if ((letters[j] == 'a') | (letters[j] == 'e' ) | (letters[j] == 'i' ) | (letters[j] == 'o' ) | (letters[j] 
  
  == 'u'))
                  {
                      for (int i = 0; i &lt; letters.Length - 1; i++)
                      {
                          x = letters[i];
                          letters[i] = letters[i + 1];
                          letters[i + 1] = x;
                      }
                  }
              }
              string s = new string(letters);
              Console.WriteLine(s);
          }
      }
  }
  </code></pre>
  
  <p>the output of the program is </p>
  
  <pre><code>ationaplic
  </code></pre>
  
  <p>but the intended output of program is </p>
  
  <pre><code>pplctnaiaio
  </code></pre>
  
  <p>Why is my code not producing my intended output?</p>
  
  <p>The edited working code is</p>
  
  <pre><code>namespace VowelSort
  {
      class Program
      {
          static void Main(string[] args)
          {
              string word = "application";
              char[] letters = word.ToCharArray();
              char x = new char { };
              int count = 0;
              for (int j = 0; j &lt; letters.Length - count; j++)
              {
                  if ((letters[j] == 'a') | (letters[j] == 'e') | (letters[j] == 'i') | (letters[j] == 'o') | (letters[j] == 'u') | (letters[j] == 'A') | (letters[j] == 'E') | (letters[j] == 'I') | (letters[j] == 'O') | (letters[j] == 'U'))
                  {
                      for (int i = j; i &lt; letters.Length - 1; i++)
                      {
                          x = letters[i];
                          letters[i] = letters[i + 1];
                          letters[i + 1] = x;
  
                      }
                      count++;
                      j--;
                  }
  
              }
              string s = new string(letters);
              Console.WriteLine(s);
              Console.WriteLine(count);
          }
      }
  }
  </code></pre>