fix averages in sorting