Initialize a hashmap to store the value-to-rank mapping.
Initialize a variable rank to 1.
Iterate through the sorted array and for each element:
a. If the element is not in the hashmap, add it with the current rank.
b. If the element is a new value (not equal to the previous one), increment rank.
Iterate through the original array and replace each element with its rank from the hashmap.