How can I sort this array by the sum value of each set in the deepest nested array?
$arr = Array(
Array(
'I am the first string.',
Array(
Array( 'round', 1, 1 ),
Array( 'rhythm', 1, 1 )
)
),
Array(
'I am the second string',
Array(
Array( 'cps', 1, 1 ),
Array( 'Hz', 1, 3 ),
Array( 'hertz', 1, 1 )
)
),
Array(
'I am the third string.',
Array(
Array( 'uucps', 1, 1 ),
Array( 'uuHz', 1, 2 ),
Array( 'uuhertz', 1, 1 )
)
)
);
I need to sort the second dimension of arrays by the sum value of third key of the deepest set(third dimension).
So the end result will look like this:
$arr = Array(
Array(
'I am the second string',
Array(
Array( 'cps', 1, 1 ),
Array( 'Hz', 1, 3 ),
Array( 'hertz', 1, 1 )
)
),
Array(
'I am the third string.',
Array(
Array( 'uucps', 1, 1 ),
Array( 'uuHz', 1, 2 ),
Array( 'uuhertz', 1, 1 )
)
),
Array(
'I am the first string.',
Array(
Array( 'round', 1, 1 ),
Array( 'rhythm', 1, 1 )
)
)
);
I know that usort might be my best bet but I can't seems to make it work for my use case.