sort(): Guard against deep or recursive structures
When sort is passed an array or multiset which is very deep or recursive
it can run out of stack space. Detect that situation and throw an
Also fixed a reference leak when comparing an empty multiset against a
non-empty multiset during sort().
Thanks to Joshua Rogers <firstname.lastname@example.org> for the report.