c# - 订购一个字符串和整数。高 int 在顶部,字符串遵循相同的顺序
问题描述
我有一些团队:
int[] numbers = new int[4];
string[] Teams = {"Team1", "Team2", "Team3","Team4"};
他们都以0分开始
Team1 0
Team2 0
Team3 3
Team4 0
如果一支球队获胜,则获得 3 bv:(Team1 vs Team3)Team3 赢得了比赛。他到达了边界的顶端。然后团队获胜...
Team3 3
Team1 0
Team2 0
Team4 0
我找不到一种方法来获取顶部具有最高int 数组的字符串数组。以第 ri 顺序。 它必须与阵列。
解决方案
您应该有一个类似于以下的类Team 。
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;}
}
}
推荐阅读
- sql - SQL 逗号错误
- ionic3 - 如何在 InAppBrowser 中停止 URL 加载
- javascript - $target.blurOverlay 不是函数
- google-apps-script - Google 应用脚本和 PropertiesService.getUserProperties()
- python - 关系逻辑回归和随机梯度下降公式
- php - 检查数据库表中是否存在令牌 - 使用 laravel
- xml - 为什么这个 XML 格式正确?
- c++ - wchar_t 究竟能代表什么?
- linux - 循环脚本,重定向到文件
- xmgrace - 无法在 xmgrace 中输入 ^