日期:2014-05-18  浏览次数:20456 次

如何根据每个单词的首字母进行排序
例如 排序前输出:while if for break switch

排序后输出:break for if switch while


给个思路,

------解决方案--------------------
C# code
SortedList mySortedList = new SortedList();
        //while if for break switch
        mySortedList["while"] = "while";
        mySortedList["if"] = "if";
        mySortedList["for"] = "for";
        mySortedList["break"] = "break";
        mySortedList["switch"] = "switch";
        if (!IsPostBack)
        {
            string s=string.Empty;
            foreach (DictionaryEntry Item in mySortedList)
            {
                s += Item.Value.ToString()+" ";
            }
            Response.Write(s);
        }