a variant of cascade sorting