apply sort algorithm on aggregated data