title: How do I sort a VARCHAR column in PostgreSQL that contains words and numbers?
body: <p>I need to order a select query using a varchar column, using numerical and text order. The query will be done in a java program, using jdbc over postgresql.</p>
  
  <p>If I use <code>ORDER BY</code> in the select clause I obtain:</p>
  
  <pre><code>1
  11
  2
  abc
  </code></pre>
  
  <p>However, I need to obtain: </p>
  
  <pre><code>1
  2
  11
  abc
  </code></pre>
  
  <p>The problem is that the column can also contain text.</p>
  
  <p>This question is similar (but targeted for SQL Server):</p>
  
  <p><a href="https://stackoverflow.com/questions/1590836/how-do-i-sort-a-varchar-column-in-sql-server-that-contains-words-and-numbers">How do I sort a VARCHAR column in SQL server that contains words and numbers?</a></p>
  
  <p>However, the solution proposed did not work with PostgreSQL.</p>
  
  <p>Thanks in advance, regards,</p>