title: Alphanumeric case in-sensitive sorting in postgres
body: <p>I am new to postrges and want to sort varchar type columns. want to explain the problem with with below example:</p>
  
  <p>table name: testsorting</p>
  
  <pre><code>   order       name
      1            b
      2            B
      3            a
      4            a1
      5            a11
      6            a2
      7            a20
      8            A
      9            a19
  </code></pre>
  
  <p><strong>case sensitive sorting (which is default in postgres) gives:</strong></p>
  
  <pre><code>select name from testsorting order by name;
  
      A
      B
      a
      a1
      a11
      a19
      a2
      a20
      b
  </code></pre>
  
  <p><strong>case in-sensitive sorting gives:</strong></p>
  
  <p>select name from testsorting order by UPPER(name);</p>
  
  <pre><code>      A
        a
        a1
        a11
        a19
        a2
        a20
        B
        b
  </code></pre>
  
  <p><strong>how can i make alphanumeric case in-sensitive sorting in postgres to get below order</strong>:</p>
  
  <pre><code>          a
            A
            a1
            a2
            a11
            a19
            a20
            b
            B
  </code></pre>
  
  <p>I wont mind the order for capital or small letters, but the order should be "aAbB"  or "AaBb"  and should not be "ABab"</p>
  
  <p>Please suggest if you have any solution to this in postgres.</p>