public static TimeSpan ShellSort(T[] items)
    where T : IComparable
{
    DateTime start = DateTime.Now;

    int inc = (int)Math.Round(items.Length / 2d);
    while (inc > 0)
    {
        for (int i = inc; i < items.Length; i++)
        {
            T temp = items[i];
            int j = i;

            while (j >= inc && items[j - inc].CompareTo(temp) > 0)
            {
                items[j] = items[j - inc];
                j -= inc;
            }

            items[j] = temp;
        }

        inc = (int)Math.Round(inc / 2.2d);
    }

    return DateTime.Now - start;
}
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Windows Azure MVP 남정현 (rkttu.com)