added photo-sort function