如何按值(DESC,数字)排序数组并保持非数字键顺序?

I have tried many things but none worked, I am sure I am missing something simple.

Here is my array:

$array['Product1'] = 500;
$array['Product2'] = 1230;
$array['Product3'] = 432;
$array['Product4'] = 2000;

Here is the result I want please!

$array['Product4'] = 2000;
$array['Product2'] = 1230;
$array['Product1'] = 500;
$array['Product3'] = 432;

Tried natcasesort, array_reverse, asort, rsort, nothing seems to work. What I am missing here?

Any help is appreciated

You tried much, but not the right thing:

arsort($array);

For more information aout arsort() see the manual: http://php.net/manual/en/function.arsort.php

You probably want arsort: http://php.net/manual/en/function.arsort.php

$array = arsort($array);

There is a comparison of the array sorting types here: http://php.net/manual/en/array.sorting.php

You can also pass sort_flags to arsort - there is a list here: http://php.net/manual/en/function.sort.php (and a link on the arsort link above)

You should end up with:

$array = arsort($array, SORT_NUMERIC);