I'm having some trouble coming up with a formula to yield a unique 'sorting code.'

I have a spreadsheet with client names in column A, and codes in column B. The codes in column B are meant to be sorted in ascending order (101, 201, 301, etc.). These codes may include duplicates. I want to write a formula to assign a 'sorting code' for each client based on ascending codes in column B--keeping all duplicates (see below).

I'm at a loss on this one. Any suggestions?


Client A 101 101-1
Client A 101 101-2
Client A 201 201-1
Client A 301 301-1
Client B 101 101-1
Client B 201 201-1
Client B 301 301-1
Client B 301 301-2
Client B 301 301-3