Optimizing sorts and minimizing contention