Advertisement
Danielos168

InsertSort

Nov 20th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.38 KB | None | 0 0
  1. static int[] InsertSort(int[] t)
  2.         {
  3.             int value,j;
  4.             for (int i = 1; i < t.Length; i++)
  5.             {
  6.                 value = t[i];
  7.                 for (j = i-1; j >= 0 && t[j] > value; j--)
  8.                 {
  9.                     t[j + 1] = t[j];
  10.                 }
  11.  
  12.                 t[j + 1] = value;
  13.             }
  14.  
  15.             return t;
  16.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement