Oops!
You're quite right, Mario. The code below corrects the problem. You can see in the output temp the element positions are each a list of the positions in which the element ranks, with more than one if needed.. The final line just assigns an element the rank of its first occurence. Either could esily be turned into a function. Also, duplicated elements do not reduce the rank of followers, so we get {1,2,5,2,4}.
Best,
David
(*a list*)
list = {1, 2, 4, 2, 3}
(* {1,2,4,2,3} *)
(* sorted list *)
sorted = Sort[list]
(* {1,2,2,3,4} *)
temp = Position[sorted, #] & /@ list
(* {{{1}},{{2},{3}},{{5}},{{2},{3}},{{4}}} *)
(*the position which each thing in the list occupies in the ordered \
list*)
First /@ temp // Flatten
(* {1,2,5,2,4} *)