I have been trying to solve this for a while now. I have an array of locations, and sub arrays of values relative to that location all taken from an xml file. For example :
Array
(
[ab15] => Array
(
[stid] => ab15
[name] => Alan Briggs
[stnm] => 2072
[lat] => 46.9814
[lon] => -67.4305
[elev] => 0
[net] => NBP
[ecrg] => nil
)
[alw] => Array
(
[stid] => alw
[name] => Alward
[stnm] => 2000
[lat] => 46.2
[lon] => -65.445
[elev] => 123
[net] => FORET
[ecrg] => NAN
)
[cwzs] => Array
(
[stid] => cwzs
[name] => Amqui
[stnm] => 489
[lat] => 48.4722
[lon] => -67.4342
[elev] => 165
[net] => DEA
[ecrg] => NAN
)
...
I need to sort these in order so that the highest [‘lat’] and lowest [‘lon’] be first and so forth. For example:
Array
(
[cwzs] => Array
(
[stid] => cwzs
[name] => Amqui
[stnm] => 489
**[lat] => 48.4722
[lon] => -67.4342**
[elev] => 165
[net] => DEA
[ecrg] => NAN
)
[ab15] => Array
(
[stid] => ab15
[name] => Alan Briggs
[stnm] => 2072
[lat] => 46.9814
[lon] => -67.4305
[elev] => 0
[net] => NBP
[ecrg] => nil
)
[alw] => Array
(
[stid] => alw
[name] => Alward
[stnm] => 2000
[lat] => 46.2
[lon] => -65.445
[elev] => 123
[net] => FORET
[ecrg] => NAN
)
...
I have no idea how to go about this, I’ve looked at a range of array sorting functions, I just can’t seem to wrap my head around the matter.
1 Answer