let ar = [0.7, 0.6, 1, 0.5, 0.4, 0.2, 0.05, 0.05, 0.04 , 0.3]; const sortMax = ar => ar.map((v, i) => ({v, i})).sort((a,b) => b.v - a.v).map(({i}) => i); alert(sortMax(ar));