fixed the indexing issue, now it will return the index in the original array not the sorted array