fix index issues for same file names while sorting files