      "collapsed": false
     },
     "outputs": [],
     "source": [
      "def insertion_sort(data):\n",
      "    if data is None or len(data) < 2:\n",
      "        return\n",
      "    for r in range(1, len(data)):\n",
      "        for l in range(r):\n",
      "            if data[l] > data[r]:\n",
      "                temp = data[r]\n",
      "                data[l+1:r+1] = data[l:r]\n",
      "                data[l] = temp\n",
      "                break"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
 
</s> remove     "def insertion_sort(data):\n",
    "    # TODO: Implement me\n",
    "    pass"
 </s> add     "class SelectionSort(object):\n",
    "\n",
    "    def sort(data):\n",
    "        # TODO: Implement me\n",
    "        pass" </s> remove     "from nose.tools import assert_equal\n",
 </s> add     "from nose.tools import assert_equal, assert_raises\n", </s> remove     "        insertion_sort(data)\n",
    "        assert_equal(data, sorted(data))\n",
 </s> add     "        assert_equal(insertion_sort.sort(data), sorted(data))\n",
    "class InsertionSort(object):\n",
    "\n",
    "    def sort(self, data):\n",
    "        if data is None:\n",
    "            raise TypeError('data cannot be None')\n",
    "        if len(data) < 2:\n",
    "            return data\n",
    "        for l in range(len(data)-1):\n",
    "            for r in range(l+1, len(data)):\n",
    "                if data[r] < data[l]:\n",
    "                    temp = data[r]\n",
    "                    data[l+1:r+1] = data[l:r]\n",
    "                    data[l] = temp\n",
    "        return data"
      "collapsed": false
     },
     "outputs": [],
     "source": [
    "class InsertionSort(object):\n",
    "\n",
    "    def sort(self, data):\n",
    "        if data is None:\n",
    "            raise TypeError('data cannot be None')\n",
    "        if len(data) < 2:\n",
    "            return data\n",
    "        for l in range(len(data)-1):\n",
    "            for r in range(l+1, len(data)):\n",
    "                if data[r] < data[l]:\n",
    "                    temp = data[r]\n",
    "                    data[l+1:r+1] = data[l:r]\n",
    "                    data[l] = temp\n",
    "        return data"
    "class InsertionSort(object):\n",
    "\n",
    "    def sort(self, data):\n",
    "        if data is None:\n",
    "            raise TypeError('data cannot be None')\n",
    "        if len(data) < 2:\n",
    "            return data\n",
    "        for l in range(len(data)-1):\n",
    "            for r in range(l+1, len(data)):\n",
    "                if data[r] < data[l]:\n",
    "                    temp = data[r]\n",
    "                    data[l+1:r+1] = data[l:r]\n",
    "                    data[l] = temp\n",
    "        return data"
    "class InsertionSort(object):\n",
    "\n",
    "    def sort(self, data):\n",
    "        if data is None:\n",
    "            raise TypeError('data cannot be None')\n",
    "        if len(data) < 2:\n",
    "            return data\n",
    "        for l in range(len(data)-1):\n",
    "            for r in range(l+1, len(data)):\n",
    "                if data[r] < data[l]:\n",
    "                    temp = data[r]\n",
    "                    data[l+1:r+1] = data[l:r]\n",
    "                    data[l] = temp\n",
    "        return data"
    "class InsertionSort(object):\n",
    "\n",
    "    def sort(self, data):\n",
    "        if data is None:\n",
    "            raise TypeError('data cannot be None')\n",
    "        if len(data) < 2:\n",
    "            return data\n",
    "        for l in range(len(data)-1):\n",
    "            for r in range(l+1, len(data)):\n",
    "                if data[r] < data[l]:\n",
    "                    temp = data[r]\n",
    "                    data[l+1:r+1] = data[l:r]\n",
    "                    data[l] = temp\n",
    "        return data"
    "class InsertionSort(object):\n",
    "\n",
    "    def sort(self, data):\n",
    "        if data is None:\n",
    "            raise TypeError('data cannot be None')\n",
    "        if len(data) < 2:\n",
    "            return data\n",
    "        for l in range(len(data)-1):\n",
    "            for r in range(l+1, len(data)):\n",
    "                if data[r] < data[l]:\n",
    "                    temp = data[r]\n",
    "                    data[l+1:r+1] = data[l:r]\n",
    "                    data[l] = temp\n",
    "        return data"
    "class InsertionSort(object):\n",
    "\n",
    "    def sort(self, data):\n",
    "        if data is None:\n",
    "            raise TypeError('data cannot be None')\n",
    "        if len(data) < 2:\n",
    "            return data\n",
    "        for l in range(len(data)-1):\n",
    "            for r in range(l+1, len(data)):\n",
    "                if data[r] < data[l]:\n",
    "                    temp = data[r]\n",
    "                    data[l+1:r+1] = data[l:r]\n",
    "                    data[l] = temp\n",
    "        return data"
    "class InsertionSort(object):\n",
    "\n",
    "    def sort(self, data):\n",
    "        if data is None:\n",
    "            raise TypeError('data cannot be None')\n",
    "        if len(data) < 2:\n",
    "            return data\n",
    "        for l in range(len(data)-1):\n",
    "            for r in range(l+1, len(data)):\n",
    "                if data[r] < data[l]:\n",
    "                    temp = data[r]\n",
    "                    data[l+1:r+1] = data[l:r]\n",
    "                    data[l] = temp\n",
    "        return data"
    "class InsertionSort(object):\n",
    "\n",
    "    def sort(self, data):\n",
    "        if data is None:\n",
    "            raise TypeError('data cannot be None')\n",
    "        if len(data) < 2:\n",
    "            return data\n",
    "        for l in range(len(data)-1):\n",
    "            for r in range(l+1, len(data)):\n",
    "                if data[r] < data[l]:\n",
    "                    temp = data[r]\n",
    "                    data[l+1:r+1] = data[l:r]\n",
    "                    data[l] = temp\n",
    "        return data"
    "class InsertionSort(object):\n",
    "\n",
    "    def sort(self, data):\n",
    "        if data is None:\n",
    "            raise TypeError('data cannot be None')\n",
    "        if len(data) < 2:\n",
    "            return data\n",
    "        for l in range(len(data)-1):\n",
    "            for r in range(l+1, len(data)):\n",
    "                if data[r] < data[l]:\n",
    "                    temp = data[r]\n",
    "                    data[l+1:r+1] = data[l:r]\n",
    "                    data[l] = temp\n",
    "        return data"
    "class InsertionSort(object):\n",
    "\n",
    "    def sort(self, data):\n",
    "        if data is None:\n",
    "            raise TypeError('data cannot be None')\n",
    "        if len(data) < 2:\n",
    "            return data\n",
    "        for l in range(len(data)-1):\n",
    "            for r in range(l+1, len(data)):\n",
    "                if data[r] < data[l]:\n",
    "                    temp = data[r]\n",
    "                    data[l+1:r+1] = data[l:r]\n",
    "                    data[l] = temp\n",
    "        return data"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
keep keep keep keep replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Update insertion sort challenge (#129)

Update constraints, test cases, code, and tests. 
sorting_searching/insertion_sort/insertion_sort_solution.ipynb