Replace triangle characters with entity references
Fix sorting on long arrays.

The old version used two iterations with two different comparators, an
approach that works only on arrays with a low number of elements. Like
the ones we use in tests...