Example warp explanation in HTML

The purpose of this HTML file is to show how warp can be used with HTML, using JavaScript to do the file inclusion that HTML on its own can't do.

An improved insert sort algorithm

Olli Nevalainen, Timo Raita and Harold Thimbleby
A simple and efficient insert sort algorithm is presented in Java. This paper uses warping (automatic code inclusion from actual program source) to ensure reliability of the published code; the code extracts in this paper are guaranteed compiled, run and tested. The preceding paper in this journal discusses both the tool warp and its rationale.

Keywords: Insert sort, Java, Quicksort, Sentinels, Warp.

This note is written in HTML. For the full paper, written in LaTeX, on which this note is based, see the full paper in PDF.


To create an insert sort algorithm to sort an array a, put the following code fragments together. The array is assumed to implement Comparable.

1 Identify sentinel position and value

2 Insert sentinel value

Choose either of the following two options, depending on whether you want an unstable or stable sort.

2.1 Unstable sort

2.2 Stable sort

3 Final phase: the main insert sort


Here is complete example code, using the unstable version above.

Example output from a run of the algorithm


The complete Java source code

The HTML-rendered Java was extracted automatically by warp from this code.