added a sorting function to the collection