Make sure that the set is sorted.

This was failing under JDK8 as we were making assumptions about how the Set would be sorted.
Update for Sakai 10.