class RSpec::Matchers::BuiltIn::ContainExactly

def match_when_sorted?

works, so it's worth a try.
the slowness of the full matching algorithm, and in common cases this
or matchers as expected items), but it's practically free compared to
This cannot always work (e.g. when dealing with unsortable items,
def match_when_sorted?
  values_match?(safe_sort(expected), safe_sort(actual))
end