title: How to sort command line arguments in ASCII order in C language
body: <p>I am struggling with a an exercise, I'm currently doing a pool in an affiliate school with 42 called 1337 (In case you're curious about why).</p>
  
  <ul>
  <li>I am supposed to write a program that displays arguments given in the command line sorted by ascii order.</li>
  <li>I should display all arguments, except argv[0].</li>
  <li>Every argument should be in it's own line (Basically put a \n).</li>
  </ul>
  
  <p>The use of printf is definitely forbidden and is considered as cheat, the only function I'm allowed to use is write(), from the unistd.h library #include </p>
  
  <p>I've done other exercises, that I'm gonna link to you, one that displays arguments normally, and one that displays them in reverse order.</p>
  
  <p>The code below literally just prints the arguments</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  
  void        ft_putchar(char ch)
  {
      write(1, &amp;ch, 1);
  }
  
  void        ft_print_params(int argc, char *argv)
  {
      int i;
  
      i = 0;
      while (i &lt; argc)
      {
          while (argv[i] != '\0')
          {
              ft_putchar(argv[i]);
              i++;
          }
          i++;
      }
  }
  
  int         main(int argc, char **argv)
  {
      int i;
  
      i = 1;
      while (i &lt; argc)
      {
          ft_print_params(argc, argv[i]);
          ft_putchar('\n');
          i++;
      }
      return (0);
  }
  </code></pre>
  
  <p>The program below, prints the arguments in reverse order.</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  
  void        ft_putchar(char ch)
  {
      write(1, &amp;ch, 1);
  }
  
  void        ft_print_params(char *argv)
  {
      int i;
  
      i = 0;
      while (argv[i] != '\0')
      {
          ft_putchar(argv[i]);
          i++;
      }
  }
  
  int         main(int argc, char **argv)
  {
      int i;
  
      i = argc;
      if (1)
      {
          while (i &gt; 1)
          {
              ft_print_params(argv[i - 1]);
              ft_putchar('\n');
              i--;
          }
      }
      return (0);  
  }
  </code></pre>
  
  <p>So I would love if someone could help me out, with either ideas, or maybe some code, and with some explanations if possible.</p>
  
  <p>Thanks.</p>