bugfix: sort array before compare