【发布时间】:2014-11-17 09:26:07
【问题描述】:
我的数组如下所示:
$colors[] = array("green", "dark green");
$colors[] = array("black", "black");
$colors[] = array("green", "light green");
$colors[] = array("blue", "dark blue");
$colors[] = array("blue", "light blue");
$colors[] = array("apricote", "apricote");
我需要按子数组的第一个值的字母升序对$colors 进行排序。 (绿色、蓝色、黑色、杏色)。
我知道如何使用usort 对数字进行排序,但对字母顺序一无所知。
结果会是这样的:
$colors[] = array("apricote", "apricote");
$colors[] = array("black", "black");
$colors[] = array("blue", "dark blue");
$colors[] = array("blue", "light blue");
$colors[] = array("green", "dark green");
$colors[] = array("green", "light green");
【问题讨论】:
-
asort($colors);有什么问题?