polynomial: replace sorts with stable sorts, to enforce consistency
of performance across platforms.