C#——快速排序

方法

public static void QuickSort(int low, int high, int[] a) // 快速排序
{
	if(low >= high) //
	{
		return;
	}
	int first = low;
	int last = high;
	int key = a[first];//用字表的第一个记录作为基准

	while(first < last)
	{
		while(first < last && a[last] >= key)
		{
			--last;
		}

		a[first] = a[last];//将比第一个小的移到低端

		while(first < last && a[first] <= key)
		{
			++first;
		}

		a[last] = a[first];//将比第一个大的移到高端
	}

	a[first] = key;//

	QuickSort(low, first-1 ,a);
	QuickSort(first+1, high, a);
}


原文地址:https://www.cnblogs.com/AlinaL/p/12852170.html