title: How to sort using 'key': C
body: <p>I am learning C. I have created a program to count frequency of words from a text file.
  My struct contains three keys (frequency, word, nextLink).</p>
  
  <p>The thing is I have sorted array of structs using key, but have no idea how to go about this one. Any guidance, links will be great.</p>
  
  <p>I am providing my arrayOfStructs sort code</p>
  
  <pre><code>void sortArray(int array[], int count)
  {
      int i,j,temp;
      for (i = 0; i &lt; count; ++i)
      {
          for (j = i + 1; j &lt; count; ++j)
          {
              if (array[i] &gt; array[j])
              {
                  temp =  array[i];
                  array[i] = array[j];
                  array[j] = temp;
              }
          }
      }
  }
  </code></pre>
  
  <p>Would this be the possible way to sort LinkedList</p>
  
  <pre><code>void sortList(struct Node *head)
  {
      struct Node *i, *j, *temp;
  
      for (i = head; i != NULL ; i-&gt;next)
      {
          for (j = head-&gt;next; j != NULL; j-&gt;next)
          {
              if (head-&gt;frequency &lt; head-&gt;next-&gt;frequency)
              {
                  temp = head;
                  head = head-&gt;next;
                  head-&gt;next = temp;
              }
          }
      }
  }
  
  struct Node
  {
      int frequency;
      char word[50];
      struct Node *next;
  };
  </code></pre>