Now I shift the low values upwards, and make a copy of index array.

This *has* been tested, and seems to work!