only sort small dicts and sets in lib.pretty

The sorting caused performance problems when displaying large collections,
even when the result would be truncated.
Merge pull request #6777 from minrk/pretty-big-set

only sort small dicts and sets in lib.pretty