What are the potential pitfalls of manually assigning ranks in PHP based on sorted data, and how can they be avoided?

Potential pitfalls of manually assigning ranks in PHP based on sorted data include the risk of incorrect rankings due to ties in the data, as well as the need to handle edge cases such as missing or duplicate values. To avoid these pitfalls, it is recommended to use a built-in PHP function like array_rank() to automatically assign ranks to the sorted data.

$data = [85, 75, 90, 75, 80];
rsort($data);
$rank = array_rank($data);

foreach ($data as $value) {
    echo "Value: $value, Rank: $rank[$value] \n";
}