fix incorrect array search in test (by sorting it first)

relates to #5621