The ksort function sorts an array by keys in ascending order.


    $capitals = array('New York' => 'Albany', 'Texas' => 'Austin', 'Florida' => 'Tallahassee');

    ksort($capitals);

    print_r($capitals);
    // Array (
    //    [Florida] => Tallahassee
    //    [New York] => Albany
    //    [Texas] => Austin
    // )