zoukankan      html  css  js  c++  java
  • List Dictionary 排序

    1、List

    List<string> temp = new List<string>();
    foreach (PlayAgentItem arg in PlayAgentConfigSection.values.Cast<PlayAgentItem>())
    {
      temp.Add(arg.IpAddr);
    }
    temp = temp.OrderBy(u => u).ToList();

    2、Dictionary

     private Dictionary<IPAddress, Seat> SeatList;
     SeatList.OrderBy(r => r.Value.ID).ToDictionary(r => r.Key, r => r.Value)

    Seat类要实现IComparable的CompareTo接口
    public class Seat, IComparable<Seat>
    {
         /// <summary>
            ///
            /// </summary>
            /// <param name="obj"></param>
            /// <returns></returns>
            public int CompareTo(Seat obj)
            {
                if (this.ID == obj.ID)
                {
                    return 0;
                }
                else if (this.ID > obj.ID)
                {
                    return 1;
                }
                else
                {
                    return -1;
                }
            }
    }
  • 相关阅读:
    sentinel-initFunc&控制台
    Sentinel-FlowSlot
    Sentinel-AuthoritySlot&SystemSlot&LogSlot
    Sentinel-DegradeSlot
    Sentinel-ClusterBuilderSlot
    Sentinel-NodeSelectorSlot
    Sentinel整体架构
    Recyclers对象池设计
    加密算法的使用场景
    FastDFS分布式
  • 原文地址:https://www.cnblogs.com/ChangTan/p/12936768.html
Copyright © 2011-2022 走看看