The formula which can help is:
[B2]=LET(src,A2:A8,u,UNIQUE(src),XLOOKUP(src,SORT(u,,-1),SEQUENCE(ROWS(u))))