instead of shifting er can swap , i am not able to understand what exactly this does
Swapping the number
@rishabh.chhabra10,
Algorithm:
1: Iterate from arr[1] to arr[n] over the array.
2: Compare the current element (key) to its predecessor.
3: If the key element is smaller than its predecessor, compare it to the elements before. Move the greater elements one position up to make space for the swapped element.
Look at the image below for a better visualization: