I have a website that is hosting some data for an iOS app through mysql and it has some ascending and descending numbers and they are displaying as 1,11,12,13,etc.,2,20,21,22,etc.
This is the sorting function on the admin site and should translate into the JSON response for the iOS app…
function sortPage($pageName,$sortBy,$sortOrder, $qry = '' ){
$getParameters = "$pageName?sortBy=$sortBy&sortOrder=$sortOrder";
if($catID!=''){
$getParameters .="&catID=$catID";
}
if($extraParams!=''){
$getParameters .='&'.$extraParams;
}
if( $qry != '')
$getParameters .= $qry ;
$url ="<a href='$getParameters' style='text-decoration:none'>";
if($sortOrder=='ASC'){
$url .="<img src='".HOST."images/up-arrow.gif' width='8' height='4' border='0' />";
}else{
$url .="<img src='".HOST."images/down-arrow.gif' width='8' height='4' border='0'/>";
}
$url .="</a>";
return $url;
}
Do I need to change the structure type to make it not order that way? It is currently int(11).
From the screenshot I can see that is not an
int(11)column but rather some string type.With this query you can fool MySQL to order the ones with the number first, if that is what you want. This will work when the number is on the left part of the value: