title: Efficiency of Selection Sort vs. Insertion Sort
body: <p>I am currently trying to implement both insertion sort and selection sort in python. Both of my implementations work. However, when I time the sorts, the selection sort consistently performs about 1.5 times faster than the insertion sort, even though my implementation of insertion sort makes about half as many comparisons as my implementation of selection sort. I can't seem to find a reason for this.</p>
  
  <pre><code>def select_sort(data):
      for i in range(len(data)):
          minimum, index = None, i
          for j in range(i, len(data)):
              if minimum is None:
                  minimum = data[j]
              if data[j] &lt; minimum:
                  minimum = data[j]
                  index = j
          data[i], data[index] = data[index], data[i]
      return data
  
  def insert_sort(data):
      for i in range(1, len(data)):
          for j in range(i, 0, -1):
              if data[j] &gt;= data[j - 1]:
                  break
              data[j], data[j - 1] = data[j - 1], data[j]
      return data
  
  def time_sort(S):
      elapsed = []
  
      start = time()
      insert_sort(copy(S))
      elapsed.append(time() - start)
  
      start = time()
      select_sort(copy(S))
      elapsed.append(time() - start)
  
      return elapsed
  </code></pre>