Skip to content

Instantly share code, notes, and snippets.

@aloisdg
Created October 5, 2021 13:40
Show Gist options
  • Save aloisdg/ea7dddeca27b66ae2e406f641abe0367 to your computer and use it in GitHub Desktop.
Save aloisdg/ea7dddeca27b66ae2e406f641abe0367 to your computer and use it in GitHub Desktop.
Is this the simplest (and most surprising) sorting algorithm ever?
// 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