惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
博客园 - 叶小钗
The Cloudflare Blog
D
DataBreaches.Net
J
Java Code Geeks
G
Google Developers Blog
L
LangChain Blog
N
Netflix TechBlog - Medium
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
小众软件
小众软件
量子位
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
博客园_首页
罗磊的独立博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog
腾讯CDC

博客园 - life++

multer /busboy 上传文件无法完成回调问题 linux系统上搭建egret构建环境(针对5.3.x 版以上) android studio 2.0 Gradle HttpProxy 设置 javascript的 parseInt 曾经的“陷井”在IE10上不见了,但还是得注意! 无法将类型为“xxxx”的对象强制转换为类型“Microsoft.SharePoint.WebPartPages.WebPart”。 ajax 12301 原因小结 被人忽悠完成的56.com我秀聊天室群发软件 WebDav基于Exchange2003开发邮件收发系统 fiddler 调试 WebDav 引起400错误处理 HTML-JS中的单双引混合处理原则 [笔记]443端口没开放让svn https连接不上 ora10ginstant 精简客户端遇到 system.data.oracleclient 需要 oracle 客户端软件8.1.7 或更高版本 手动调用__doPostBack('xx','') 在IE6, 下留意 javascript:void(0);问题。 让relative容器里的元素的z-index高于body下的遮照层 [原]SWFUpload 在IE9下不显示问题及IE9中模态窗下flash文件选择问题的处理 JQuery-easyui accordion 滚动条在IE6下“丢失”的处理 asp.net Ajax 页中使用jquery-easyui的显示问题处理 equal 与 == 自问自答
胡乱写个 List string 类型排序。
life++ · 2010-11-24 · via 博客园 - life++

不得不也写了个排序。 先用着。有空再改进。

structs.Sort(new Comparison<Model.TableStruct>((t1, t2) => 
            {
                var i = 0;
                var n1 = t1.ColName.ToLower();
                var n2 = t2.ColName.ToLower();

                while (n1.Length > i + 1 && n2.Length > i + 1 && n1[i] == n2[i])
                {
                    i++;
                }

                if (n1[i] > n2[i])
                    return 1;
                if (n1[i] < n2[i])
                    return -1;                
                if (n1.Length < n2.Length)
                    return -1;
                if (n1.Length > n2.Length)
                    return 1;

                return 0;
            }));
 public int CompareTo(object obj)
        {
            if (obj is TableStruct)
            {
                var t1 = this;
                var t2 = (TableStruct)obj;

                var i = 0;
                var n1 = t1.ColName.ToLower();
                var n2 = t2.ColName.ToLower();

                while (n1.Length > i + 1 && n2.Length > i + 1 && n1[i] == n2[i])
                {
                    i++;
                }

                if (n1[i] > n2[i])
                    return 1;
                if (n1[i] < n2[i])
                    return -1;
                if (n1.Length < n2.Length)
                    return -1;
                if (n1.Length > n2.Length)
                    return 1;

                return 0;
            }
            else
            {
                throw new Exception("不能比较");
            }
        }

posted @ 2010-11-24 23:45  life++  阅读(1234)  评论()    收藏  举报