Order a text field numerically in views
Can you use views instead?
The Views Natural Sort module may help you

Otherwise, in drupal 7 you can go with 

$query-&gt;orderby( 'CAST(n.title AS SIGNED)', 'ASC');


Check also  CAST Mysql documentation