Sort array by value in ascending order (low to high)

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

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

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

array:sort_values(['x'=> 2, 'y' => 1],true)
#=> [ "y" => 1, "x" => 2 ]

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

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

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