Metric math calculates new time series from existing metrics or expressions, for example sums, averages, percentages or sorting.
e1 from section 3.2. Choose Add math (1), Filter (2), then Top 10 by sum (3).
e2 with SORT(METRICS(), SUM, DESC, 10) is added (1).
Edit e2 and replace it with the expression below (1), then choose Apply (2). It sorts the results of e1 by their average value, from high to low, and keeps only the first 3.
SORT(e1, AVG, DESC, 3)

e1 (1) so only the result of e2 (2) is graphed. The legend now shows only the 3 series with the highest average, numbered in order (3).
See Using math expressions with CloudWatch metrics for all functions.