sorting code change