change sort function into xptfunc