PHP 버전
4+
$products = [
    '사과' => 3000,
    '바나나' => 1000,
    '체리' => 5000
];

// 값 기준 내림차순으로 정렬
arsort($products);

// 결과 출력
print_r($products);
출력
$countries = [
    'US' => 'United States',
    'KR' => 'Korea',
    'JP' => 'Japan',
    'FR' => 'France',
    'AU' => 'Australia'
];

// 국가명 기준 내림차순으로 정렬
arsort($countries);

// 결과 출력
print_r($countries);
출력
// PHP 8.2.0 전
arsort(array &$array, int $flags = SORT_REGULAR): true

// PHP 8.2.0부터
arsort(array &$array, int $flags = SORT_REGULAR): bool
$items_1 = [
    'a' => 12,
    'b' => 'abc',
    'c' => '15',
    'd' => 7,
    'e' => 'Banana'
];

arsort($items_1, SORT_NUMERIC);
// 숫자 기준 내림차순 정렬 (SORT_NUMERIC)
// 배열의 모든 값(value)을 숫자로 간주하여 내림차순 정렬
// 숫자로 변환할 수 있는 문자열('15')은 해당 숫자로 취급 → 내림차순에서 앞쪽
// 숫자로 변환할 수 없는 문자열('abc', 'Banana')은 0으로 간주 → 뒤쪽에 위치

var_dump($items_1);
/*
array(5) {
  ["c"]=> string(2) "15"     // 문자열 '15'는 숫자 15로 변환해서 비교 → 맨 앞
  ["a"]=> int(12)            // 숫자 12
  ["d"]=> int(7)             // 숫자 7
  ["b"]=> string(3) "abc"    // 숫자로 변환 불가 → 0 → 뒤쪽
  ["e"]=> string(6) "Banana" // 숫자로 변환 불가 → 0 → 뒤쪽
                             // 같은 값일 경우 원래 배열에서의 순서가 유지되어 "Banana"가 "abc" 뒤에 위치
}
*/

////////////////////

$items_2 = [
    'a' => 12,
    'b' => 'abc',
    'c' => '15',
    'd' => 7,
    'e' => 'Banana'
];

arsort($items_2, SORT_STRING);
// 문자열 기준 내림차순 정렬 (SORT_STRING)
// 배열의 모든 값(value)을 문자열로 간주하여 사전식(lexicographical) 내림차순 정렬
// 실제 값(value)와 키(key)는 그대로 유지

var_dump($items_2);
/*
array(5) {
                               // 숫자 형태의 문자열이 일반 문자열보다 작은 값이므로 숫자 형태의 문자열이 뒤에 위치함
  ["b"]=> string(3) "abc"      // 'abc'
  ["e"]=> string(6) "Banana"   // 'Banana'
  ["d"]=> int(7)               // '7' 문자열로 비교
  ["c"]=> string(2) "15"       // '15' 문자열로 비교
  ["a"]=> int(12)              // '12' 문자열로 비교
}
*/