コード例 #1
0
        static List <int> Sort(List <int> Elements, string Method)
        {
            ScriptEngine Engine = new ScriptEngine("jscript");
            ParsedScript Parsed;
            string       RawMethod = GetRawMethodFromApi(Method);

            if (!string.IsNullOrEmpty(RawMethod))
            {
                for (var i = 0; i < Elements.Count; i++)
                {
                    for (var j = 0; j < Elements.Count - 1 - i; j++)
                    {
                        Parsed = Engine.Parse(RawMethod);
                        var Result = (bool)Parsed.CallMethod(Method, Elements[j + 1], Elements[j]);
                        if (Result)
                        {
                            Swap(ref Elements, j, j + 1);
                        }
                    }
                }
                return(Elements);
            }
            return(new List <int>());
        }