sort legend by count or y-value