added sorting of variables by Pt