Not sorting properly

I tried to dry run my code but I didn’t find any error in logic so please tell me whats happening wrong in my code
code - https://ide.codingblocks.com/s/183330
I want to correct myself

@anubhavb11 you were working in values so it was not swapping properly
here take a look you have to work on indexes


hope your doubt is resolved if yes dont forget to mark it resolved :smiley:

Could you please tell me with example where that code is not swaping properly
in this case 4
2
-18
45
30
because in dry run i was not able to find any error

in swap function @anubhavb11 you were doing swap(a[i] , idx) so a[i] was not going to different position
if you have to swap to array values you have to write in term of swap( a[],a[]) otherwise it will not change position

Ok i got it thank you very much