title: How do I sort a linked list in a alphabetical order in c
body: <p>I'm trying to sort my linked list in alphabetical order, but it looks like my sorting algorithm doesn't. How can I sort my list?</p>
  
  <pre><code>typedef struct  s_file
  {
      char        *file_name;
      struct      s_file *next;
  }               t_file;
  
  void    sort_alpha(t_file **begin_list)
  {
      t_file  *list;
      char    *tmp;
  
      list = *begin_list;
      if (list)
      {
          while (list)
          {
              if (strcmp(list-&gt;file_name, list-&gt;next-&gt;file_name) &lt; 0)
              {
                  tmp = list-&gt;file_name;
                  list-&gt;file_name = list-&gt;next-&gt;file_name;
                  list-&gt;next-&gt;file_name = tmp;
              }
              list = list-&gt;next;
          }
      }
  }
  </code></pre>