1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ListObjectSort
  9. {
  10. public class Program
  11. {
  12. public static void Main(string[] args)
  13. {
  14. List<Student> list = new List<Student>();
  15. Student stu1 = new Student()
  16. {
  17. Number = ,
  18. Name = "石敏媛"
  19. };
  20. list.Add(stu1);
  21.  
  22. Student stu2 = new Student()
  23. {
  24. Number = ,
  25. Name = "梁秀秀"
  26. };
  27. list.Add(stu2);
  28.  
  29. Student stu3 = new Student()
  30. {
  31. Number = ,
  32. Name = "苏敏敏"
  33. };
  34. list.Add(stu3);
  35.  
  36. Student stu4 = new Student()
  37. {
  38. Number = ,
  39. Name = "褚丽丽"
  40. };
  41. list.Add(stu4);
  42. DisplayInfomation(list);
  43.  
  44. Comparison<Student> compari = new Comparison<Student>(Compart);
  45. list.Sort(compari);
  46. DisplayInfomation(list);
  47. }
  48.  
  49. public static void DisplayInfomation(List<Student> list)
  50. {
  51. Console.WriteLine("--------------------------");
  52. foreach (Student stu in list)
  53. {
  54. Console.WriteLine(stu.Number + "\t\t" + stu.Name);
  55. }
  56. Console.WriteLine("--------------------------");
  57. }
  58.  
  59. public static int Compart(Student stu1, Student stu2)
  60. {
  61. int result = ;
  62. CaseInsensitiveComparer objCompare = new CaseInsensitiveComparer();
  63. result = objCompare.Compare(stu1.Number, stu2.Number);
  64. return result;
  65. }
  66. }
  67.  
  68. public class Student
  69. {
  70. public int Number { get; set; }
  71. public string Name { get; set; }
  72. }
  73. }

C# List<object> 按特定字段排序的更多相关文章

  1. 对文本行按特定字段排序(前N个字符或后N个字符),TCPL 练习5-17

    The C programming language 的关于文本行排序的问题有很多种要求的方式,在对每行的字段排序方面,最简单的是例如对前N个字符或者末位N个字符进行排序,更高一点的要求是,对特殊符号 ...

  2. C#中List按特定字段排序

    有一个类,如Student,有学号.数学成绩.语文成绩, 存在List列表中,要将List按数学成绩排序,怎么办呢? List<Student> scores=GetScores(); s ...

  3. SQL 按特定字段值排序

    SQL 按特定字段值排序的代码,有需要的朋友可以参考下. id, name shandong01 name1 shandong02 name2 shandong03 name3 beijing01 n ...

  4. Java 多字段排序Comparator(兼容Date,Integer,Doubel,Long)

    Java 反射类:ReflexUtil public class ReflexUtil { static Logger logger = LoggerFactory.getLogger(ReflexU ...

  5. EFCore+Mysql仓储层建设(分页、多字段排序、部分字段更新)

    前沿 园子里已有挺多博文介绍了EFCore+Mysql/MSSql如何进行使用,但实际开发不会把EF层放在Web层混合起来,需要多个项目配合结构清晰的进行分层工作,本文根据个人实践经验总结将各个项目进 ...

  6. java实现按对象某个字段排序,排序字段和规则自定义

    @SuppressWarnings({ "unchecked", "rawtypes" }) private <T> void sort(List& ...

  7. List<model>需要根据特定字段求差集的实现

    list对象不能直接使用Except等封装好的函数,因为内存地址不一样(还有一些数虽然主数据一致但是update/create信息也不一致,对,我碰到的需求就是这么难受 TOT) 这时候我们的需求很多 ...

  8. Elasticsearch 6.2.3版本 string 类型字段 排序 报错 Fielddata is disabled on text fields by default

    背景说明 最近在做一个 Elasticsearch 的分页查询,并且对查询结果按照特定字段进行排序的功能. 但是执行结果却报错,报错信息如下: { "error": { " ...

  9. 在Java中使用Collections.sort 依据多个字段排序

    一.如何使用Collections工具类进行排序 使用Collections工具类进行排序主要有两种方式: 1.对象实现Comparable接口,重写compareTo方法 /** * @author ...

随机推荐

  1. [bzoj]2705: [SDOI2012]Longge的问题[数论][数学][欧拉函数][gcd]

    [bzoj]P2705 OR [luogu]P2303 Longge的问题 Description Longge的数学成绩非常好,并且他非常乐于挑战高难度的数学问题.现在问题来了:给定一个整数N,你需 ...

  2. BP算法演示

    本文转载自https://mattmazur.com/2015/03/17/a-step-by-step-backpropagation-example/ Background Backpropaga ...

  3. RedisTemplate访问Redis数据结构(一)——String

    当对String数据结构进行操作时,推荐直接使用spring-data-redis提供的StringRedisTemplate,其配置如下 <bean id="stringRedisT ...

  4. Oracle In子句

    Oracle In子句 作者:初生不惑 Oracle基础 评论:0 条 Oracle技术QQ群:175248146 在本教程中,您将学习如何使用Oracle IN运算符来确定值是否与列表或子查询中的任 ...

  5. es之java分页操作

    按照一般的查询流程来说,如果我想查询前10条数据: · 1 客户端请求发给某个节点 · 2 节点转发给个个分片,查询每个分片上的前10条 · 3 结果返回给节点,整合数据,提取前10条 · 4 返回给 ...

  6. LR之流程

    一.新建事务 如何估算一个业务流程呢?一个业务流程的持续时间:登录,预定机票等等的花费时间,通常是几个步骤构成的,所以在LR中需要标记事物,作为评测业务的时间. 1.打开Basic_Tutorial脚 ...

  7. 论文keywords和规则匹配的baseline

    详细的思路可以参照小论文树立0317 关键词分为以下几类: t/****一些通用的过滤词,这些通用的过滤词可以使用和节目一起出现的词语,结合tf-idf看出来么?*****/    public st ...

  8. fedora禁用(开机启动)服务和进程管理

    首先要查看有哪些(开机启动)服务 chkconfig --list 或者: systemctl list-units 然后, 根据需要进行禁用服务的开机启动: chkconfig service_na ...

  9. Maven install报错:MojoFailureException ,To see the full stack trace of the errors, re-run Maven with the -e switch.解决

    报错日志: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".SLF4J: Defaulting to ...

  10. VMware 虚拟化编程(9) — VMware 虚拟机的快照

    目录 目录 前文列表 VMware 虚拟机的快照 快照的执行过程 删除快照 快照类型 Quiseced Snapshot 前文列表 VMware 虚拟化编程(1) - VMDK/VDDK/VixDis ...