O(n) sorting array by value - get indexes
Every problem can be solved with yet another indirection:

First create B as an array of self-indexes - i.e set B[i] = i for all i.  Next create a 'comparator' object around A, which compares integers i and j by actually comparing A[i] with A[j].  Now sort B using this comparator.