排序的另一种思路

            Console.WriteLine("start:出自http://www.cnblogs.com/ahjesus 尊重作者辛苦劳动成果,转载请注明出处,谢谢!");

            List<int> sourceArr = new List<int> { 99, 51, 61, 41, 8, 73, -3, 225, 3, 10, 0 };

            int maxIndex = sourceArr.Max() * 10 + 1;

            object[] replaceArr = new object[maxIndex];

            sourceArr.ForEach(it => { replaceArr[it < 0 ? ~it * 10 : it * 10] = it; });

            IEnumerable<object> result = replaceArr.Where(it => it != null);

            foreach (var it in result) {

                Console.WriteLine(it);

            }

 

你可能感兴趣的:(排序)