Below is my code on set intersection and union test that I did. I don\'t understand why it the output is incorrect when I commented out the sort function. Why is the sort necess
In case you care about the official wording from the standard (§25.4.5/1):
This section defines all the basic set operations on sorted structures. They also work with multisets (23.4.7) containing multiple copies of equivalent elements. The semantics of the set operations are generalized to multisets in a standard way by defining set_union() to contain the maximum number of occurrences of every element, set_intersection() to contain the minimum, and so on. [emphasis added]
That section includes the specifications for std::includes, std::set_union, std::set_intersection, std::set_difference, and std::set_symmetric_difference, so the requirement for sorted inputs applies to all of these algorithms.