A simplest sorting algorithm that sorts in quadratic time

Showcases the simplest sorting algorithm that works in quadratic time. From here.

The pseudocode for this algo can be seen below (sorts an array with n elements in non decreasing order):

for i from 0 to n:
    for j from 0 to n:
        if Ar[i] < Ar[j]:
            swap(Ar[i], Ar[j])

This repository houses a go program that uses exactly this algo, but animates how it works on your terminal! Demo below:


Assuming you have git and go installed, you can simply clone and run.

git clone

go run main.go

Should work on any modern Linux terminal. Untested on MacOS and Windows.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

GIPHY App Key not set. Please check settings

Better Scrum Through Essence

EquiHome — An app for transparent distribution of chores