add new ctree sorting code