fix sidecar handling if sidecar was found before images, fix sorting