Optimize canonical reordering algorithm
Optimize canonical reordering algorithm

Well, it *is* a bubble sort, but we can be smart about not doing
an O(n^2) pass over the whole string. The bubble sort works fine
here because it is fast when the slice is already sorted or almost
sorted which is exactly what to be expected during normalization.

ilammy/sash