sort photos by primary