comparison page sorting function