用PHP排序数组 - 数字排序

I have a bunch of numbers. Let's use these as an example: 7, 18, 24, 53, 75, 15

When i use rsort() on my array, it orders it something like this:

  • 75
  • 7
  • 53
  • 24
  • 18

However, this is not what I want. I want my sorting algorithm to sort my array in numeric order descending, so that it looks like this:

  • 75
  • 53
  • 24
  • 18
  • 15

What sorting algorithm is the right one? I've tried a few but none have done the trick.

Use SORT_NUMERIC flag:

rsort($myArray, SORT_NUMERIC)

Without flags, rsort (as well as sort) sorts items without changing types, i.e. strings are compared lexicographically.