Fix the sorting of variables