![]() |
VOOZH | about |
Given an integer array, sort its elements in ascending order while retaining and displaying their original indexes, ensuring the initial positions of elements are preserved after sorting.
Examples:
Input: arr[] = {20, 40, 30, 10}
Output:
Element | Original index
10 | 3
20 | 0
30 | 2
40 | 1
Follow these steps to sort the array while keeping track of original indexes:
Implementation
4 3 5 2 10 1 20 0