separate the last digit and sort according to the group and sum

Top