implementing sorting when a collection is listed