ksort

ksort — 对数组按照键名排序

$fruits = array(“d”=>”lemon”, “a”=>”orange”, “b”=>”banana”, “c”=>”apple”);
ksort($fruits);
foreach ($fruits as $key => $val) {
echo “$key = $val\n”;
}

a = orange
b = banana
c = apple
d = lemon