I have an array of names which I need to sort by
- lastname
- firstname
- mi
I can sort by one field (i.e. lastname) using usort
usort($name_apha, function($a, $b) {
return $a['ln'] - $b['ln'];
});
But that only gets me 1/3 of the way.
Question: How can I sort all three fields (ln, fn them mi) to get the proper results? Below is an example of the data that needs sorting.
array (size=5)
0 =>
array (size=4)
'ID' => int 425
'ln' => string 'Bolware' (length=10)
'fn' => string 'Christian' (length=9)
'mi' => string '' (length=0)
1 =>
array (size=4)
'ID' => int 423
'ln' => string 'Bernstein' (length=9)
'fn' => string 'Bear' (length=5)
'mi' => string 'D.' (length=2)
2 =>
array (size=4)
'ID' => int 419
'ln' => string 'Bellweather' (length=7)
'fn' => string 'Brent' (length=9)
'mi' => string '' (length=0)
3 =>
array (size=4)
'ID' => int 356
'ln' => string 'Bayleaf, III' (length=13)
'fn' => string 'Joe' (length=5)
'mi' => string 'X.' (length=2)
4 =>
array (size=4)
'ID' => int 336
'ln' => string 'Public' (length=6)
'fn' => string 'John' (length=4)
'mi' => string 'Q.' (length=2)