Whitespace (esoteric programming language) Sort Algorithm

82 views Asked by At

I want to implement a sort algo in Whitespace. As you know whitespace only uses stack and heap. Any idea which sort algo can be easily implemented?

1

There are 1 answers

0
Kevin Cruijssen On

Since Whitespace only has a single stack and single heap, and in-place sorting algorithm would be ideal.

Insertion sort was the first that came to mind, where the sorting and reading from STDIN can be combined into one. Looking into it a bit further: Shell sort with an Insertion implementation is probably your best bet. In fact, on Rosetta Code's Shell sort page I've been able to find a Whitespace sort program, including explanation and working ideone link.

Since Whitespace compilers can each have their own implementation, this algorithm doesn't work in all online Whitespace compilers. In TIO, it for examples gives an error because of negative indices. And the Whitespace vii5ard compiler is unfortunately broken since a couple months ago, so not sure if it would have worked there. I might take another look later on to modify the program for it to work on TIO as well, unless you want to try to do this yourself to better understand the sorting algorithm used in the Whitespace program.