Seems straightforward enough. For j values of 1 to i it will not do anything because the largest element in the array has already been moved to position i in some earlier iteration in the i loop. For j values greater than i it then proceeds to find the largest remaining element place in position i.
Edit: I’m leaving my incorrect thought above as is for posterity. As pointed out when j is less than i it does of course swap again resulting in a more difficult (for me) visualization of what the end result looks like. Time to have some fun with it (could read about it, but programming is more fun and I like to experiment).
Seems straightforward enough. For j values of 1 to i it will not do anything because the largest element in the array has already been moved to position i in some earlier iteration in the i loop. For j values greater than i it then proceeds to find the largest remaining element place in position i.
Edit: I’m leaving my incorrect thought above as is for posterity. As pointed out when j is less than i it does of course swap again resulting in a more difficult (for me) visualization of what the end result looks like. Time to have some fun with it (could read about it, but programming is more fun and I like to experiment).