reduce the complexity of sorting