title: Sort array alphabetically, upper letter always first
body: <p>I want to sort arrays alphabetically but I want to have upper case letter always first. What I already achieved is a simple sort, which doesn't take to account size of letters. Shall I put a special condition for it?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is what I want to achieve:
  <code>AaaAdDcCFfgGhHI</code> should be sorted like this: <code>AAaaCcDdFfGgHhI</code></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define N 5
  
  int compare(const void *w1, const void *w2);
  
  int main(void) {
      char s1[N][15] = {
          { "azghtdffopAsAfp" },
          { "poiuyjklhgADHTp" },
          { "hgjkFfGgBnVUuKk" },
          { "lokijuhygtfrdek" },
          { "AaaAdDcCFfgGhHI" } };
  
      char *wsk;
      int i, j;
      wsk = s1;
  
      for (i = 0; i &lt; N; i++) {
          for (j = 0; j &lt; 15; j++) {
              printf("%c", s1[i][j]);
          }
          printf("\n");
      }
      for (i = 0; i &lt; N; i++)
          qsort(s1[i], 15, sizeof(char), compare);
  
      printf("\n");
      for (i = 0; i &lt; N; i++) {
          for (j = 0; j &lt; 15; j++) {
              printf("%c", s1[i][j]);
          }
          printf("\n");
      }
      return 0;
  }
  
  int compare(const void *w1, const void *w2) {
      char *a1 = w1;
      char *a2 = w2;
  
      while (*a1 &amp;&amp; *a2) {
          register r = tolower(*a1) - tolower(*a2);
          if (r)
              return r;
          ++a1;
          ++a2;
  
      }
      return tolower(*a1) - tolower(*a2);
  }
  </code></pre>