You can do a sort into another list then a comparison with the unsorted list then a 3rd list where you can store the indices i.e nlog(n) + n^2
or just O(n^2)
Note: this is Pseudo code
vector x = {15, 3, 0, 20};
vector y = sort(x);
vector z;
for(int i = 0; y < y.size(); i++){
for(int j = 0; j < y.size(); j++){
if(y[i] == x[j]){
z.push_back(j);
}
}
}