How to track index of unsorted array after sorting that array?

  • Question belongs on StackOverflow, or more likely in a school study group.

    Choose a better data structure.

    Don't write your own sort function. Use the features of the language and standard library. Your code is about 3x longer than necessary.