• + 1 comment

    Hi, the pivot should be smaller than the number you are swapping with, otherwise the final sequence would be lexicographically smaller than the original. So, we are finding the smallest number in the suffix, greater than the pivot, which is 3 in the tutorial. Hope that helped.