     "outputs": [],
     "source": [
      "from collections import OrderedDict\n",
      "\n",
      "def group_ordered(list_in):\n",
      "    result = OrderedDict()\n",
      "    for value in list_in:\n",
      "        result.setdefault(value, []).append(value)\n",
      "    return [v for group in result.values() for v in group]"
     ]
 
</s> remove     "    test.test_group_ordered()\n",
 </s> add     "    test.test_group_ordered(group_ordered)\n",
    "    try:\n",
    "        test.test_group_ordered(group_ordered_alt)\n",
    "    except NameError:\n",
    "        # Alternate solutions are only defined\n",
    "        # in the solutions file\n",
    "        pass\n", </s> remove     "    def test_group_ordered(self):\n",
    "        assert_equal(group_ordered(None), None)\n",
    "        assert_equal(group_ordered([]), [])\n",
    "        assert_equal(group_ordered([1]), [1])\n",
    "        assert_equal(group_ordered([1,2,1,3,2]),[1,1,2,2,3])\n",
    "        assert_equal(group_ordered(['a','b','a']),['a','a','b'])\n",
    "        assert_equal(group_ordered([1,1,2,3,4,5,2,1]),[1,1,1,2,2,3,4,5])\n",
    "        assert_equal(group_ordered([1,2,3,4,3,4]),[1,2,3,3,4,4])\n",
 </s> add     "    def test_group_ordered(self,func):\n",
    "\n",
    "        assert_equal(func(None), None)\n",
    "        assert_equal(func([]), [])\n",
    "        assert_equal(func([1]), [1])\n",
    "        assert_equal(func([1,2,1,3,2]),[1,1,2,2,3])\n",
    "        assert_equal(func(['a','b','a']),['a','a','b'])\n",
    "        assert_equal(func([1,1,2,3,4,5,2,1]),[1,1,1,2,2,3,4,5])\n",
    "        assert_equal(func([1,2,3,4,3,4]),[1,2,3,3,4,4])\n", </s> remove    "execution_count": null,
 </s> add    "execution_count": 2, </s> remove     test = TestFoo()
    test.test_foo()
 </s> add     test = TestGroupOrdered()
    test.test_group_ordered(group_ordered)
    try:
        test.test_group_ordered(group_ordered_alt)
    except NameError:
        # Alternate solutions are only defined
        # in the solutions file
        pass </s> remove    "execution_count": 3,
 </s> add    "execution_count": 1,
    "def group_ordered_alt(list_in):\n",
     "outputs": [],
     "source": [
      "from collections import OrderedDict\n",
      "\n",
    "def group_ordered_alt(list_in):\n",
      "    result = OrderedDict()\n",
      "    for value in list_in:\n",
      "        result.setdefault(value, []).append(value)\n",
      "    return [v for group in result.values() for v in group]"
     ]
keep keep keep keep replace keep keep keep keep keep
 added alternate solution w/ test 
arrays_strings/group_items/group_ordered_solution.ipynb