Jump to content

Sort float values from Array


Reignfire

Recommended Posts

Hi,

 

This is the output from a var_dump($array); command:

array (size=381)
  0 => 
    array (size=2)
      'Name' => string 'apple' (length=6)
      'Number' => float 0.368844763
  1 => 
    array (size=2)
      'Name' => string 'Blueberry' (length=
      'Number' => float 5.59E-6
  2 => 
    array (size=2)
      'Name' => string 'Cinnamon' (length=5)
      'Number' => float -0.0006947
  3 => 
    array (size=2)
      'Name' => string 'Date' (length=10)
      'Number' => float 0.001584453
...
...
...

I want to sort this array from the highest 'Number' float value to the smallest. I tried sorting it with rsort($array,SORT_NUMERIC); but that doesn't give the correct output.

 

What kind of 'sort' should i use to do this?

Link to comment
https://forums.phpfreaks.com/topic/288435-sort-float-values-from-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.