int[] nums = { 23, 300, 2400, 2300, 100, 1, 10, 20, 15 }; QuickSort(nums, 0, nums.Length - 1); Console.WriteLine(String.Join(",", nums)); void QuickSort(int[] nums, int low, int high) { if(low < high) { int pivot = Partition(nums, low, high); QuickSort(nums, low, pivot - 1); QuickSort(nums, pivot + 1, high); } } int Partition(int[] nums, int low, int high) { int i = low - 1; int pivot = nums[high]; for(int j = low; j < high; j++) { if(nums[j] < pivot) { Swap(nums, j, ++i); } } Swap(nums, high, ++i); return i; } void Swap(int[] nums, int j, int i) { int tmp = nums[j]; nums[j] = nums[i]; nums[i] = tmp; }