var arr = [5, 1, -7, 3, 6, 8, 0, -1, -3];
// Create an array that pairs the values with the indices
for (var paired=[],i=0,len=els.length;i<len;++i) paired[i] = [arr[i],i];
// result: [[5,0],[1,1],[-7,2],[3,3],[6,4],[8,5],[0,6],[-1,7],[-3,8]]
// Sort that array by the values (first element)
paired.sort(function(a,b){ a=a[0]; b=b[0]; return a<b?-1:a>b?1:0; });
// result: [[-7,2],[-3,8],[-1,7],[0,6],[1,1],[3,3],[5,0],[6,4],[8,5]]
// Create another array that has just the (now-sorted) indices (second element)
for (var indices=[],i=0;i<len;++i) indices[i] = paired[i][1];
// result: [2, 8, 7, 6, 1, 3, 0, 4, 5]