using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Sort
{
public class InsertSort
{
public int[] arrForSort = new int[100];
public InsertSort(int[] arr)
{
this.arrForSort = arr;
}
public int[] Execute()
{
int i, j, temp;
for (i = 1; i < arrForSort.Length; i++)
{
temp = arrForSort[i];
for (j = i; j > 0 && temp < arrForSort[j-1]; j--)
{
arrForSort[j] = arrForSort[j - 1];
}
arrForSort[j] = temp;
}
return arrForSort;
}
}
}
|