Sort array by values in reverse order (high to low)

array:sort_values_reverse(ARRAY $array, BOOL $preserve_keys=FALSE) : ARRAY

array:sort_values_reverse([1,3,2,2])
#=> [ 3, 2, 2, 1 ]

array:sort_values_reverse(['x'=> 2, 'y' => 1])
#=> [ 2, 1 ]

# note: set second argument to TRUE if you want the keys
array:sort_values_reverse(['x'=> 2, 'y' => 1], true)
#=> [ "x" => 2, "y" => 1 ]

array:sort_values_reverse(["foo",'-10',-10.3,3,0,"good"])
#=> [ 3, "good", "foo", 0, "-10", -10.3 ]

array:sort_values_reverse([])
#=> []

Copyright ©2013-2022 SunSed®. All rights reserved.