-1

I have some teams:

int[] numbers = new int[4];
string[] Teams = {"Team1", "Team2", "Team3","Team4"};

they all start with 0 points

Team1   0
Team2   0
Team3   3
Team4   0

if a team wins gets 3 b.v:(Team1 vs Team3) Team3 won the game. he gets to the top of the bord. then team wins ...

Team3   3
Team1   0
Team2   0
Team4   0

I can't find a way to get the string array with the highest int array on top. in the rith order. IT HAS TO BE WITH ARRAY'S.

1 Answers1

0

You should have a class Team similar to as follows.

using System;
using System.Collections.Generic;
using System.Linq;
                    
public class Program
{
    public static void Main()
    {
        var list = new List<Team>();
        list.Add(new Team{ Score = 1, TeamName = "Test"});
        list.Add(new Team{ Score = 1, TeamName = "Test 2"});
        list.Add(new Team{ Score = 1, TeamName = "Test 3"});
        list.Add(new Team{ Score = 4, TeamName = "Test 4"});
        list.Add(new Team{ Score = 1, TeamName = "Test 5"});
        
        var ordered = list.OrderByDescending(l => l.Score);
        ordered.Dump();
    }
    
    public class Team
    {
        public int Score {get;set;}
        public string TeamName {get;set;}
    }
}

https://dotnetfiddle.net/

Joel Fleischman
  • 414
  • 2
  • 5
  • 1
    Not sure it makes sense to store a score in a `Team` class, though, does it? A `score` is usually for a particular game (or possibly a series), while a `Team` can be around for many seasons. – Rufus L Sep 14 '20 at 20:12