Cliques and sorting