Rework FnCallFold to use VarRefValueToJson and sorting helpers