added new option to sort data in the compile function