title: C++ insertion sort
body: <p>I have this function called WordSort(worddata W [], int count) that is fed two variables 
  1 - worddata is the array holding information on a given word in a file. count is just the counter variable to see which word in the array we are looking at.</p>
  
  <p>the words.txt file that is read into this program would just be a string of words.</p>
  
  <pre><code>this is a list of words
  there are letters and numbers
  23 people recommend this program.
  </code></pre>
  
  <p>Heres the function:</p>
  
  <pre><code>void WordSort (worddata W [], int count)
  {
    for (int i=1; i &lt; count; i++)
           {
             for (int j=i; j &gt; 0 &amp;&amp; W[j-1].word &gt; W[j].word; j--)
               {
                 Swap(W[j], W[j-1]);
               }
           }
  }
  </code></pre>
  
  <p>The swap function is suppose to swap every element with the one before it as long as j > 0 or the list is over. Im confused on how to complete the swap function, here's the example i was given.</p>
  
  <pre><code>void Swap (worddata &amp; a, worddata &amp; b)
  {
   int += a;
   a = b;
   b =+;
  }
  </code></pre>
  
  <p>Swap is suppose to swap every element with the one before it </p>
  
  <p>I think the WordSort function works fine, the only thing missing is the Swap function. Could anyone point me in the right direction or explain insertion sorting better to me?</p>