title: C: How to sort a Struct by one of its element? Can't use pointers
body: <p>How do I sort struct like this one:</p>
  
  <pre><code>typedef struct
  {
      int weight;
      int price;
      Color color;
      Equip equip;
  }Cars;
  </code></pre>
  
  <p>by one of it's attributes like price, or weight? Automobil array is previously declared.
  I can't use pointers, and any other built-in function.</p>
  
  <pre><code>Cars automobil[5]; 
  Cars mobilOne={};
  
  for(i=0; i&lt;5; i++)
  {
      if((i+1)==5)
      {
          break;
      }else
      {
          if (automobil[i].weight&gt; automobil[i+1].weight)
          {
              mobilOne = automobil[i];
              automobil[i] = automobil[i+1];
              automobil[i+1] = mobilOne;
          }
      }
  }
  </code></pre>
  
  <p>I tried to do this, this way, but it does not do anything...
  Also if someone could tell me, how can I pass a struct like this one into a function I would be really thankful!</p>