sort arrays before comparing them