Improves the deterministic sorting algorithm