Hello everyone. I have the following multidimensional array in PHP:
Array (
[0] => Array ( [0] => teste0 [1] => 1 )
[1] => Array ( [0] => teste1 [1] => 1 )
[2] => Array ( [0] => teste2 [1] => 2 )
[3] => Array ( [0] => teste3 [1] => 2 )
[4] => Array ( [0] => teste4 [1] => 2 )
[5] => Array ( [0] => teste5 [1] => 3 )
[6] => Array ( [0] => teste6 [1] => 4 )
[7] => Array ( [0] => teste7 [1] => 4 )
)
I would like to rank this array according to the number of equal values that are in the [1] (numeric) value. This would produce the following result:
Array (
[0] => Array ( [0] => teste2 [1] => 1 )
[1] => Array ( [0] => teste3 [1] => 1 )
[2] => Array ( [0] => teste4 [1] => 1 )
[3] => Array ( [0] => teste0 [1] => 2 )
[4] => Array ( [0] => teste1 [1] => 2 )
[5] => Array ( [0] => teste6 [1] => 4 )
[6] => Array ( [0] => teste7 [1] => 4 )
[7] => Array ( [0] => teste5 [1] => 3 )
)
How to do this rankings using PHP or Javascript?