sort by appearance cleanup