1 of 3

JavaScript ES6, 87 82 bytes

(a,b={})=>a.map((l,i)=>(b[l]=b[l]+1||1,[...a].sort((a,b)=>a-b).indexOf(l)+b[l]-1))

Don't like using an object but will try to find a better way to keep track of dupes.