You don't need a fresh quicksort implementation, you can use
qsort
as it stands:
- store every array item in a struct containing its value and its original index (ending up with an array of such structs)
- define your comparison function for taking two of such structs as parameters
- use standard
qsort
for ordering the array of structs.