sort list before comparing