- array_combine: documentation ( source)
- array_multisort: documentation ( source)
- print_r: documentation ( source)
- arsort: documentation ( source)
- array_keys: documentation ( source)
- range: documentation ( source)
<?php
$assoc = [
70 => 1,
82 => 5,
61 => 3,
55 => 1,
34 => 2,
53 => 2,
21 => 4,
13 => 5,
];
$arsort = $assoc;
arsort($arsort);
$keys = array_keys($assoc);
array_multisort($assoc, SORT_DESC, range(1, count($assoc)), $keys);
$assoc = array_combine($keys, $assoc);
print_r(array($assoc, $arsort));