没事总结了一下平时C#中比较常见的排序算法,其中有稳定的 也有不稳定的,使用时自行斟酌,下面是具体脚本:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
int[] data = { 5, 6, 9, 8, 7, 2, 3, 1, 4, 0 };
int temp;
//选择排序 每一次从待排序的数据元素中选出最小(或最大)的一个元素,存放在序列的起始位置 (不稳定)
void Select()
{
for (int i = 0; i < data.Length - 1; i++)
{
for (int j = i + 1; j < data.Length; j++)
{
if (data[i] > data[j])
{
temp = data[i];
data[i] = data[j];
data[j] = temp;
}
}
}
}
/* -------------