例如:幻灯片50,幻灯片6,幻灯片40 排序完后:幻灯片6,幻灯片40,幻灯片50
代码语言:javascript复制public class PathCompare : IComparer<string>
{
public int Compare(string x, string y)
{
string[] aBuf = x.Split('\');
string[] bBuf = y.Split('\');
string[] aNameBuf = aBuf[aBuf.Length - 1].Split('.');
string[] bNameBuf = bBuf[bBuf.Length - 1].Split('.');
if (aNameBuf[0].Length > bNameBuf[0].Length)
{
return 1;
}
else if (aNameBuf[0].Length < bNameBuf[0].Length)
{
return -1;
}
else if (aNameBuf[0].Length == bNameBuf[0].Length)
{
return aNameBuf[0].CompareTo(bNameBuf[0]);
}
return 0;
}
}