added sortLegend