I was inserting them one by one at the *head* of the list, which meant
that the stable sort was ensuring that they stayed in exactly the
opposite order to what the original bubblesort would have done.
If this fixes the problem I'll change the code to use a STAILQ.