Finished sort and delete logic for img_viewer