How to compute the sum of ranks for each group

Sum of ranks in group $i$

 Arrange all observations from smallest to largest, and mark the observations which belong to group $i$ The rank of each observation is its position in this ordered list. If there are ties, assign them the average of the ranks they occupy Sum the ranks that belong to group $i$