title: sorting array of structures using bubble sort - how to speed up exchange of struct members
body: <p>I have a structure consisting of two elements <code>char *word</code> and <code>int number</code>. When I want to sort them using bubble sort, I have to write exchange parts for both of them:</p>
  
  <pre><code>int i,j,tmp;
      char * temp;
      for(i=0; i&lt;max;i++)
      {
          for(j=0;j&lt;max-i;j++)
          {
              if(strcmp(array[j].word,array[j+1].word)&gt;0)
              {
                  temp=array[j].word;
                  array[j].word=array[j+1].word;
                  array[j+1].word=temp;
                  tmp=array[j].number;
                  array[j].number=array[j+1].number;
                  array[j+1].number=tmp;
  
              }
          }
      }
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT</strong> My struct declaration </p>
  
  <pre><code>typedef struct{
      char *word;
      int number;
  }
  words;
  words *array=NULL;
  </code></pre>
  
  <hr>
  
  <p>What if I had n elements in the array ? That would be very time consuming to exchange everything. Is there any way to omit this?</p>
  
  <p>OF COURSE except for other sorting algorithms, which I don't want to use (like <code>qsort</code>).</p>