Answer the question
In order to leave comments, you need to log in
How to sort a multidimensional array by two parameters at once?
Please tell me how to sort an array like this:
array(3) {
["beta"]=> array(4) {
["b"]=> string(1) "..."
["c"]=> string(1) "..."
["a"]=> string(1) "..."
["d"]=> string(1) "..."
}
["alpha"]=> array(4) {
["d"]=> string(1) "..."
["c"]=> string(1) "..."
["b"]=> string(1) "..."
["a"]=> string(1) "..."
}
["gamma"]=> array(4) {
["c"]=> string(1) "..."
["d"]=> string(1) "..."
["a"]=> string(1) "..."
["b"]=> string(1) "..."
}
array(3) {
["alpha"]=> array(4) {
["a"]=> string(1) "..."
["b"]=> string(1) "..."
["c"]=> string(1) "..."
["d"]=> string(1) "..."
}
["beta"]=> array(4) {
["a"]=> string(1) "..."
["b"]=> string(1) "..."
["c"]=> string(1) "..."
["d"]=> string(1) "..."
}
["gamma"]=> array(4) {
["a"]=> string(1) "..."
["b"]=> string(1) "..."
["c"]=> string(1) "..."
["d"]=> string(1) "..."
}
}
Answer the question
In order to leave comments, you need to log in
Well, you can use the ksort function;
ksort($array);
foreach($array as $key=>$value) {
ksort($array[$key]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question