title: Why is insertion sort so fast compared to other sorting algorithms?
body: <p>I've been testing the speed of various other sorting algorithms (Selection, Quick, Bubble, Shell, Radix, etc) along with Insertion Sort. However, Insertion Sort seems to be the fastest algorithm by far. I always thought Quick Sort would be the fastest.</p>
  
  <p>Here is my code for the Insertion Sort and Timer functions in Python 3.</p>
  
  <pre><code>def InsertionSort(argShuffledList):
      for index in range(1,len(argShuffledList)):
  
          currentvalue = argShuffledList[index]
          position = index
  
          while position&gt;0 and argShuffledList[position-1]&gt;currentvalue:
              argShuffledList[position]=argShuffledList[position-1]
              position = position-1
  
          argShuffledList[position]=currentvalue
      return argShuffledList
  
  def Timer(argFunction, *args): ## function for timing functions
      dblStart = time.clock()
      argFunction(*args)
      intTime = "%.2f" % ((time.clock() - dblStart) * 1000000)
      message = "Elasped Time: " + str(intTime) + " microseconds"
      return message
  
  insertionSortList = InsertionSort(insertionCopyList) 
  timeInsertionSortList = Timer(InsertionSort, insertionCopyList)
  </code></pre>