SHARE
TWEET

Untitled

a guest Jul 15th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main() {
  2.   print(insertionSort([8,9, 4, 2, 6,10,12]));
  3. }
  4.  
  5. List<int> insertionSort(List<int> list) {
  6.   for (int j = 1; j < list.length; j++) {
  7.     int key = list[j];
  8.  
  9.     int i = j - 1;
  10.  
  11.     while (i >= 0 && list[i] > key) {
  12.       list[i + 1] = list[i];
  13.       i = i - 1;
  14.       list[i + 1] = key;
  15.     }
  16.   }
  17.   return list;
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top