Created
October 5, 2021 13:40
-
-
Save aloisdg/ea7dddeca27b66ae2e406f641abe0367 to your computer and use it in GitHub Desktop.
Is this the simplest (and most surprising) sorting algorithm ever?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://news.ycombinator.com/item?id=28758106 | |
// https://arxiv.org/abs/2110.01111 | |
using System; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
var n = new []{3,2,4,1}; | |
Sort(n); | |
n.Dump(); | |
} | |
private static void Sort(int[] A) | |
{ | |
for (var i = 0; i < A.Length; i++) | |
for (var j = 0; j < A.Length; j++) | |
if (A[i] < A[j]) | |
(A[i], A[j]) = (A[j], A[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment