using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace InsertSort{public class Program{static void Main(string[] args){List<int> list = new List<int>() { 3, 1, 2, 9, 7, 8, 6 };Console.WriteLine("排序前:" + string.Join(",", list));InsertSort(list);Console.WriteLine("排序后:" + string.Join(",", list));}static void InsertSort(List<int> list){//无须序列for (int i = 1; i < list.Count; i++){var temp = list[i];int j;//有序序列for (j = i - 1; j >= 0 && temp < list[j]; j--){list[j + 1] = list[j];}list[j + 1] = temp;}}}}