Moved the sorting of photos into the collection code