简单排序
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sort { struct _maxValue { public int maxIndex; public int maxValue; } class Program { static int Sort(int [] intArray) { _maxValue maxValue; int count=0; while (intArray.Length - count >= 2) { maxValue.maxIndex = 0; maxValue.maxValue = intArray[0]; for (int i = 1; i < intArray.Length-count; i++) { if(intArray[i]>maxValue.maxValue) { maxValue.maxIndex = i; maxValue.maxValue = intArray[i]; //最大值和索引赋值给maxValue } } count++; intArray[maxValue.maxIndex] = intArray[intArray.Length - count]; intArray[intArray.Length - count] = maxValue.maxValue; } return 0; } static void Main(string[] args) { int[] myArray = { 55, 4, 88, 62, 31, 102, 44, 23, 6, 99, 556 }; Sort(myArray); for (int i = 0; i < myArray.Length; i++) { Console.WriteLine(myArray[i]); } Console.ReadKey(); } } }