added pie-chart sorting function