What is a most optimal way to merge and sort 2 sets?

Viewed 23

So, say you have 2 sets with unknown properties. So the order and the size of each set is unknown. How would we merge and sort these 2 sets into one set?

The solution I have is to simply add the 2 sets into one set and perform a merge sort.

I feel as if there is a better way. Does anyone have any ideas?

1 Answers

Typically you would concatenate the sets and then sort them as a single set, that is almost as simple as it gets. I'm guessing you are using Python for this if that's the case you can use function sorted().

Related