Demo entry 2376708

Shell Sort

   

Submitted by Shane Duffy on Aug 16, 2015 at 17:58
Language: Swift. Code size: 325 Bytes.

func insertionSort() {
   var x, y, key : Int
   
   for (x = 0; x < numberList.count; x++) {
      key = numberList[x]
      
      for (y = x; y > -1; y--) {
         if (key < numberList[y]) {
            numberList.removeAtIndex(y + 1)
            numberList.insert(key, atIndex: y)
         }
      }
   }
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).