implements queue sorting and merge parallel sorting (in sharded envs, when applicable)