Pass a second parameter to the sort functions to specify how you want the values sorted
$array["1"] = "someval1"; $array["2"] = "someval2"; $array["3"] = "someval3"; $array["10"] = "someval4"; $array["100"] = "someval5"; $array["20"] = "someval6"; $array["200"] = "someval7"; $array["30"] = "someval8"; $array["300"] = "someval9"; var_dump($array); ksort($array, SORT_STRING); var_dump($array);