News for hackers. Stuff that matters.
Re:Is this the simplest (and most surprising) sorting algori... by BoppreH on Tuesday October 05, 2021 @11:32AM (#28760829)
Not quite, your algorithm has j going from i+1 to n, and swapping when a[i] > a[j].

OP's algorithm has both indexes going from 1 to n, and swapping when a[i] < a[j].

Yours is more efficient and easy to see why it's correct, but OP's is slightly simpler and more surprising.

Re:Is this the simplest (and most surprising) sorting algori... by svat on Tuesday October 05, 2021 @11:46AM (#28761049)
Oh yes, good point: I got carried away; there is a difference! Simplicity is subjective (I think mine is simpler of course :P), but the algorithm in the post is indeed more surprising.
Re:Is this the simplest (and most surprising) sorting algori... by pricecomstock on Tuesday October 05, 2021 @12:10PM (#28761378)
Your algorithm does appear in Section 3.1 of the linked paper by the name "Exchange Sort"