当前位置: 首页>>代码示例>>C#>>正文


C# List.Sort方法代码示例

本文整理汇总了C#中Data.List.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# List.Sort方法的具体用法?C# List.Sort怎么用?C# List.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Data.List的用法示例。


在下文中一共展示了List.Sort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MergeFiles

        public static void MergeFiles(Repository repo)
        {
            var f1 = repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.UniqueEmailAddressesFilename;
            var f2 = repo.StorageWrapper.Data.MineableDataDirectory + Extractor.LinkedInFilename;
            var f3 = repo.StorageWrapper.Data.MineableDataDirectory + Extractor.IgnoreListFilename;

            if (!File.Exists(f1))
            {
                Console.WriteLine("Unable to locate " + f1);
                return;
            }

            if (!File.Exists(f2))
            {
                Console.WriteLine("Unable to locate " + f2);
                return;
            }

            if (!File.Exists(f3))
            {
                Console.WriteLine("Unable to locate " + f3);
                return;
            }

            var mozilla = File.ReadLines(f1).ToList();
            var linkedIn = File.ReadLines(f2).ToList();
            var ignore = File.ReadLines(f3).ToList();
            var final = new List<string>();

            foreach (var line in mozilla.Where(line => !final.Contains(line.ToLower())).Where(line => ignore.All(ignorePart => !line.ToLower().Contains(ignorePart.ToLower()))))
            {
                final.Add(line.ToLower());
            }
            foreach (var line in linkedIn.Where(line => !final.Contains(line.ToLower())).Where(line => ignore.All(ignorePart => !line.ToLower().Contains(ignorePart.ToLower()))))
            {
                final.Add(line.ToLower());
            }

            final.Sort();

            File.WriteAllLines(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.ConvergedEmailAddressesFilename, final);

            var domains = final.Where(x => x.Contains('@')).Select(x => x.Split('@')[1]).Distinct().ToList();

            domains.Sort();

            File.WriteAllLines(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.UniqueDomainsFilename, domains);

            if (UIRetriever.GetBool(String.Format("View {0}?", Extractor.ConvergedEmailAddressesFilename)))
            {
                FileVisualiser.Show(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.ConvergedEmailAddressesFilename);
            }

            if (UIRetriever.GetBool(String.Format("View {0}?", repo.StorageWrapper.Data.MineableDataResultsDirectory)))
            {
                DirectoryVisualiser.ShowFile(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.ConvergedEmailAddressesFilename);
            }
        }
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:58,代码来源:FileMerger.cs

示例2: WriteTable

 void WriteTable()
 {
     int teamIndex = 0;
       int scoreIndex = 1;
       int currentRow = 1;
       List<Team> teams = new List<Team>(Program.main.archive.settings.teams);
       teams.Sort();
       foreach(var t in teams) {
     // Figure out relation and write text
     var title = new Label();
     title.Text = t.name;
     title.TextAlign = ContentAlignment.MiddleCenter;
     title.Dock = DockStyle.Fill;
     table.Controls.Add(title, teamIndex, currentRow);
     var score = new Label();
     score.Text = t.score + " " + Program.main.archive.settings.messages.fakePointsName;
     score.TextAlign = ContentAlignment.MiddleCenter;
     score.Dock = DockStyle.Fill;
     table.Controls.Add(score, scoreIndex, currentRow);
     currentRow += 1;
       }
 }
开发者ID:svmnotn,项目名称:cuddly-octo-adventure,代码行数:22,代码来源:Result.cs


注:本文中的Data.List.Sort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。