ОК, а как насчет LINQ ?
Что-то вроде
public class Player
{
public string Name;
public double Rank;
}
List<List<Player>> someOtherList = new List<List<Player>>
{
new List<Player>
{
new Player {Name = "A", Rank = 1},
new Player {Name = "B", Rank = 2}
},
new List<Player>
{
new Player {Name = "A", Rank = 2},
new Player {Name = "C", Rank = 1}
}
};
List<Player> plrs =
(from p in someOtherList.SelectMany(singleList => singleList)
group p by p.Name into g
select new Player { Name = g.Key, Rank = g.Average(x => x.Rank) })
.OrderBy(x => x.Rank)
.ToList();
foreach (Player p in plrs)
{
OverallPlayers.Add(p.Rank + ". " + p.Name);
}
EDIT
Изменен, чтобы выглядеть как код ОП. Я настоятельно рекомендую вам потратить некоторое время на этот учебник LINQ, как только вы почувствуете себя лучше ...
List<Star[]> stars = new List<Star[]>
{
new[]
{
new Star {Name = "A", Points = 1},
new Star {Name = "B", Points = 2}
},
new[]
{
new Star {Name = "A", Points = 2},
new Star {Name = "C", Points = 1}
}
};
List<Star> plrs =
(from p in stars.SelectMany(singleList => singleList)
group p by p.Name into g
select new Star { Name = g.Key, Points = g.Average(x => x.Points) })
.OrderBy(x => x.Points)
.ToList();
foreach (Star p in plrs)
{
//OverallPlayers.Add(p.Rank + ". " + p.Name);
}