Refactored how sorting of collections works