/// <summary> ///Bubble Sort Method 1/// </summary> /// <param name= "list" ></param> Public Static voidBubblesort (int[] list) { for(inti =0; I < list. Length; i++) { for(intj = i; J < list. Length; J + +) { if(List[i] <List[j]) { inttemp =List[i]; List[i]=List[j]; LIST[J]=temp; } } } } /// <summary> ///Insert Sort Method/// </summary> /// <param name= "list" ></param> Public Static voidInsertionsort (int[] list) { for(inti =1; I < list. Length; i++) { intt =List[i]; intj =i; while(J >0) && (List[j-1] >t)) {LIST[J]= List[j-1]; --J; } List[j]=T; } }//// <summary> ///Select Sort Method/// </summary> /// <param name= "list" ></param> Public Static voidSelectionsort (int[] list) { intmin; for(inti =0; I < list. Length-1; i++) {min=i; for(intj = i +1; J < list. Length; J + +) { if(List[j] <list[min]) min=J; } intt =List[min]; List[min]=List[i]; List[i]=T; } } //// <summary> ///Hill Sort Method/// </summary> /// <param name= "list" ></param> Public Static voidShellsort (int[] list) { intInc; for(inc =1; Inc <= list. Length/9; inc =3* Inc +1) ; for(; Inc >0; Inc/=3) { for(inti = inc +1; I <= list. Length; i + =Inc) { intt = list[i-1]; intj =i; while(J > Inc) && (List[j-inc-1] >t)) {List[j-1] = List[j-inc-1]; J-=Inc; } list[j-1] =T; } } }Private Static voidSwap (ref intLref intr) {ints; S=l; L=R; R=s; } ///Quick Sort Method/// </summary> /// <param name= "list" ></param> /// <param name= "Low" ></param> /// <param name= "High" ></param> Public Static voidSort (int[] list,intLowintHigh ) { intpivot; intL, R; intmid; if(High <=Low )return; Else if(High = = Low +1) { if(List[low] >List[high]) Swap (refList[low],refList[high]); return; } Mid= (low + high) >>1; Pivot=List[mid]; Swap (refList[low],refList[mid]); L= Low +1; R=High ; Do { while(l <= R && List[l] <pivot) L++; while(List[r] >=pivot) R--; if(L <r) Swap (refList[l],refList[r]); } while(L <R); List[low]=List[r]; LIST[R]=pivot; if(Low +1<r) Sort (list, low, R-1); if(R +1<High ) Sort (list, R+1, high); }
Summary of C # sorting algorithms