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


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

    asort($capitals);

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