My array looks like this:
$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");
I need to sort $colors
alphabetically ascending by the first value of the subarrays. (green, blue, black, apricote).
I know how to use usort
for sorting numerical, but dont have any clue about alphabetical.
The result would be something like this:
$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");