{
  "id": "sorting/selection-sort",
  "version": 1,
  "deterministic": true,
  "url": "/dsa/sorting/selection-sort",
  "topic": {
    "slug": "sorting",
    "title": "Sorting"
  },
  "title": "Selection Sort",
  "tagline": "Find the smallest. Put it in front. Repeat.",
  "vizKind": "bars",
  "complexity": {
    "time": {
      "best": "O(n²)",
      "average": "O(n²)",
      "worst": "O(n²)"
    },
    "space": "O(1)",
    "growth": "quadratic",
    "note": "Always n²/2 comparisons — best case, worst case, sorted, shuffled, it makes no difference. But at most n−1 swaps ever, which is the fewest of any simple sort."
  },
  "code": {
    "javascript": "function selectionSort(a) {\n  for (let i = 0; i < a.length - 1; i++) {\n    let min = i;\n    for (let j = i + 1; j < a.length; j++) {\n      if (a[j] < a[min]) {\n        min = j;\n      }\n    }\n    if (min !== i) {\n      [a[i], a[min]] = [a[min], a[i]];\n    }\n  }\n  return a;\n}",
    "python": "def selection_sort(a):\n    for i in range(len(a) - 1):\n        lo = i\n        for j in range(i + 1, len(a)):\n            if a[j] < a[lo]:\n                lo = j\n\n        # one swap per pass — that's the whole point\n        if lo != i:\n            a[i], a[lo] = a[lo], a[i]\n\n    return a\n",
    "java": "int[] selectionSort(int[] a) {\n  for (int i = 0; i < a.length - 1; i++) {\n    int min = i;\n    for (int j = i + 1; j < a.length; j++) {\n      if (a[j] < a[min]) {\n        min = j;\n      }\n    }\n    if (min != i) {\n      int t = a[i]; a[i] = a[min]; a[min] = t;\n    }\n  }\n  return a;\n}",
    "cpp": "vector<int> selectionSort(vector<int> a) {\n  for (int i = 0; i + 1 < a.size(); i++) {\n    int min = i;\n    for (int j = i + 1; j < a.size(); j++) {\n      if (a[j] < a[min]) {\n        min = j;\n      }\n    }\n    if (min != i) {\n      swap(a[i], a[min]);\n    }\n  }\n  return a;\n}"
  },
  "defaultInput": [
    8,
    3,
    5,
    1,
    9,
    2,
    7
  ],
  "defaultTarget": null,
  "inputHint": "Type numbers separated by spaces. Count how few swaps it makes.",
  "pitfalls": [
    {
      "wrong": "Swapping every time you find a smaller value.",
      "right": "Only remember *where* the smallest is. Swap once, at the end of the pass. Swapping as you go throws away the algorithm's one advantage."
    },
    {
      "wrong": "Expecting it to be faster on sorted input.",
      "right": "It isn't. Selection sort has no early exit — it must scan the whole remainder to know what the minimum is. Same cost, always."
    },
    {
      "wrong": "Starting the inner scan at index 0 each pass.",
      "right": "Start at i + 1. Everything before i is already finished and re-scanning it is pure waste."
    }
  ],
  "quiz": [
    {
      "q": "How many swaps does selection sort make on a list of 10 items?",
      "options": [
        "At most 9",
        "About 45",
        "About 100",
        "It depends on the order"
      ],
      "answer": 0,
      "why": "One swap per pass, and there are n−1 passes. Very few moves — that's the whole personality of this sort."
    },
    {
      "q": "Selection sort on an already-sorted list of 100 items does how many comparisons?",
      "options": [
        "99",
        "About 5,000",
        "0",
        "About 700"
      ],
      "answer": 1,
      "why": "About n²/2 ≈ 5,000. It has no way to notice the list is already sorted — it must scan to be sure."
    },
    {
      "q": "When would selection sort genuinely be the right choice?",
      "options": [
        "When the list is huge",
        "When moving an item is very expensive but comparing is cheap",
        "When the list is nearly sorted",
        "Never, under any circumstances"
      ],
      "answer": 1,
      "why": "It makes at most n−1 moves. If a 'move' means physically relocating something costly, minimising moves is worth a lot of extra looking."
    }
  ],
  "problems": [
    {
      "name": "Sort an Array",
      "difficulty": "Medium",
      "url": "https://leetcode.com/problems/sort-an-array/"
    },
    {
      "name": "Kth Largest Element in an Array",
      "difficulty": "Medium",
      "url": "https://leetcode.com/problems/kth-largest-element-in-an-array/"
    },
    {
      "name": "Sort Colors",
      "difficulty": "Medium",
      "url": "https://leetcode.com/problems/sort-colors/"
    }
  ],
  "trace": {
    "note": "Each frame is one immutable step: data snapshot, pointers, per-index roles, executing code line, and a one-sentence explanation.",
    "length": 47,
    "frames": [
      {
        "data": [
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [],
        "highlights": [],
        "codeLine": 1,
        "variables": {},
        "explanation": "Selection sort hunts for the smallest value in what's left, then puts it where it belongs. One swap per pass — no more.",
        "stats": {
          "comparisons": 0,
          "swaps": 0
        }
      },
      {
        "data": [
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 0
          }
        ],
        "highlights": [
          {
            "index": 0,
            "role": "active"
          }
        ],
        "codeLine": 3,
        "variables": {
          "i": 0,
          "min": 0,
          "smallestSoFar": 8
        },
        "explanation": "Start of pass 1. Assume 8 is the smallest thing left, then try to prove yourself wrong.",
        "stats": {
          "comparisons": 0,
          "swaps": 0
        }
      },
      {
        "data": [
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 0
          },
          {
            "name": "j",
            "index": 1
          }
        ],
        "highlights": [
          {
            "index": 0,
            "role": "pivot"
          },
          {
            "index": 1,
            "role": "compare"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 0,
          "j": 1,
          "min": 0,
          "smallestSoFar": 8
        },
        "explanation": "3 is smaller than 8. New smallest.",
        "stats": {
          "comparisons": 1,
          "swaps": 0
        }
      },
      {
        "data": [
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 1
          }
        ],
        "highlights": [
          {
            "index": 1,
            "role": "pivot"
          }
        ],
        "codeLine": 6,
        "variables": {
          "i": 0,
          "j": 1,
          "min": 1,
          "smallestSoFar": 3
        },
        "explanation": "Remember position 1. 3 is the smallest we've seen so far.",
        "stats": {
          "comparisons": 1,
          "swaps": 0
        }
      },
      {
        "data": [
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 1
          },
          {
            "name": "j",
            "index": 2
          }
        ],
        "highlights": [
          {
            "index": 1,
            "role": "pivot"
          },
          {
            "index": 2,
            "role": "compare"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 0,
          "j": 2,
          "min": 1,
          "smallestSoFar": 3
        },
        "explanation": "5 is not smaller than 3. Keep looking.",
        "stats": {
          "comparisons": 2,
          "swaps": 0
        }
      },
      {
        "data": [
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 1
          },
          {
            "name": "j",
            "index": 3
          }
        ],
        "highlights": [
          {
            "index": 1,
            "role": "pivot"
          },
          {
            "index": 3,
            "role": "compare"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 0,
          "j": 3,
          "min": 1,
          "smallestSoFar": 3
        },
        "explanation": "1 is smaller than 3. New smallest.",
        "stats": {
          "comparisons": 3,
          "swaps": 0
        }
      },
      {
        "data": [
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 3
          }
        ],
        "highlights": [
          {
            "index": 3,
            "role": "pivot"
          }
        ],
        "codeLine": 6,
        "variables": {
          "i": 0,
          "j": 3,
          "min": 3,
          "smallestSoFar": 1
        },
        "explanation": "Remember position 3. 1 is the smallest we've seen so far.",
        "stats": {
          "comparisons": 3,
          "swaps": 0
        }
      },
      {
        "data": [
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 3
          },
          {
            "name": "j",
            "index": 4
          }
        ],
        "highlights": [
          {
            "index": 3,
            "role": "pivot"
          },
          {
            "index": 4,
            "role": "compare"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 0,
          "j": 4,
          "min": 3,
          "smallestSoFar": 1
        },
        "explanation": "9 is not smaller than 1. Keep looking.",
        "stats": {
          "comparisons": 4,
          "swaps": 0
        }
      },
      {
        "data": [
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 3
          },
          {
            "name": "j",
            "index": 5
          }
        ],
        "highlights": [
          {
            "index": 3,
            "role": "pivot"
          },
          {
            "index": 5,
            "role": "compare"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 0,
          "j": 5,
          "min": 3,
          "smallestSoFar": 1
        },
        "explanation": "2 is not smaller than 1. Keep looking.",
        "stats": {
          "comparisons": 5,
          "swaps": 0
        }
      },
      {
        "data": [
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 3
          },
          {
            "name": "j",
            "index": 6
          }
        ],
        "highlights": [
          {
            "index": 3,
            "role": "pivot"
          },
          {
            "index": 6,
            "role": "compare"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 0,
          "j": 6,
          "min": 3,
          "smallestSoFar": 1
        },
        "explanation": "7 is not smaller than 1. Keep looking.",
        "stats": {
          "comparisons": 6,
          "swaps": 0
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 0,
            "role": "swap"
          },
          {
            "index": 3,
            "role": "swap"
          }
        ],
        "codeLine": 10,
        "variables": {
          "i": 0,
          "min": 3,
          "swaps": 1
        },
        "explanation": "1 is the winner, so swap it into position 0. 8 takes its old seat.",
        "stats": {
          "comparisons": 6,
          "swaps": 1
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 0,
            "role": "sorted"
          }
        ],
        "codeLine": 2,
        "variables": {
          "i": 0,
          "swaps": 1
        },
        "explanation": "1 is locked in at position 0. It will never move again.",
        "stats": {
          "comparisons": 6,
          "swaps": 1
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 1
          }
        ],
        "highlights": [
          {
            "index": 1,
            "role": "active"
          },
          {
            "index": 0,
            "role": "sorted"
          }
        ],
        "codeLine": 3,
        "variables": {
          "i": 1,
          "min": 1,
          "smallestSoFar": 3
        },
        "explanation": "Start of pass 2. Assume 3 is the smallest thing left, then try to prove yourself wrong.",
        "stats": {
          "comparisons": 6,
          "swaps": 1
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 1
          },
          {
            "name": "j",
            "index": 2
          }
        ],
        "highlights": [
          {
            "index": 1,
            "role": "pivot"
          },
          {
            "index": 2,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 1,
          "j": 2,
          "min": 1,
          "smallestSoFar": 3
        },
        "explanation": "5 is not smaller than 3. Keep looking.",
        "stats": {
          "comparisons": 7,
          "swaps": 1
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 1
          },
          {
            "name": "j",
            "index": 3
          }
        ],
        "highlights": [
          {
            "index": 1,
            "role": "pivot"
          },
          {
            "index": 3,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 1,
          "j": 3,
          "min": 1,
          "smallestSoFar": 3
        },
        "explanation": "8 is not smaller than 3. Keep looking.",
        "stats": {
          "comparisons": 8,
          "swaps": 1
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 1
          },
          {
            "name": "j",
            "index": 4
          }
        ],
        "highlights": [
          {
            "index": 1,
            "role": "pivot"
          },
          {
            "index": 4,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 1,
          "j": 4,
          "min": 1,
          "smallestSoFar": 3
        },
        "explanation": "9 is not smaller than 3. Keep looking.",
        "stats": {
          "comparisons": 9,
          "swaps": 1
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 1
          },
          {
            "name": "j",
            "index": 5
          }
        ],
        "highlights": [
          {
            "index": 1,
            "role": "pivot"
          },
          {
            "index": 5,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 1,
          "j": 5,
          "min": 1,
          "smallestSoFar": 3
        },
        "explanation": "2 is smaller than 3. New smallest.",
        "stats": {
          "comparisons": 10,
          "swaps": 1
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 5
          }
        ],
        "highlights": [
          {
            "index": 5,
            "role": "pivot"
          },
          {
            "index": 0,
            "role": "sorted"
          }
        ],
        "codeLine": 6,
        "variables": {
          "i": 1,
          "j": 5,
          "min": 5,
          "smallestSoFar": 2
        },
        "explanation": "Remember position 5. 2 is the smallest we've seen so far.",
        "stats": {
          "comparisons": 10,
          "swaps": 1
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 5
          },
          {
            "name": "j",
            "index": 6
          }
        ],
        "highlights": [
          {
            "index": 5,
            "role": "pivot"
          },
          {
            "index": 6,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 1,
          "j": 6,
          "min": 5,
          "smallestSoFar": 2
        },
        "explanation": "7 is not smaller than 2. Keep looking.",
        "stats": {
          "comparisons": 11,
          "swaps": 1
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 1,
            "role": "swap"
          },
          {
            "index": 5,
            "role": "swap"
          },
          {
            "index": 0,
            "role": "sorted"
          }
        ],
        "codeLine": 10,
        "variables": {
          "i": 1,
          "min": 5,
          "swaps": 2
        },
        "explanation": "2 is the winner, so swap it into position 1. 3 takes its old seat.",
        "stats": {
          "comparisons": 11,
          "swaps": 2
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          }
        ],
        "codeLine": 2,
        "variables": {
          "i": 1,
          "swaps": 2
        },
        "explanation": "2 is locked in at position 1. It will never move again.",
        "stats": {
          "comparisons": 11,
          "swaps": 2
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 2
          }
        ],
        "highlights": [
          {
            "index": 2,
            "role": "active"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          }
        ],
        "codeLine": 3,
        "variables": {
          "i": 2,
          "min": 2,
          "smallestSoFar": 5
        },
        "explanation": "Start of pass 3. Assume 5 is the smallest thing left, then try to prove yourself wrong.",
        "stats": {
          "comparisons": 11,
          "swaps": 2
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 2
          },
          {
            "name": "j",
            "index": 3
          }
        ],
        "highlights": [
          {
            "index": 2,
            "role": "pivot"
          },
          {
            "index": 3,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 2,
          "j": 3,
          "min": 2,
          "smallestSoFar": 5
        },
        "explanation": "8 is not smaller than 5. Keep looking.",
        "stats": {
          "comparisons": 12,
          "swaps": 2
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 2
          },
          {
            "name": "j",
            "index": 4
          }
        ],
        "highlights": [
          {
            "index": 2,
            "role": "pivot"
          },
          {
            "index": 4,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 2,
          "j": 4,
          "min": 2,
          "smallestSoFar": 5
        },
        "explanation": "9 is not smaller than 5. Keep looking.",
        "stats": {
          "comparisons": 13,
          "swaps": 2
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 2
          },
          {
            "name": "j",
            "index": 5
          }
        ],
        "highlights": [
          {
            "index": 2,
            "role": "pivot"
          },
          {
            "index": 5,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 2,
          "j": 5,
          "min": 2,
          "smallestSoFar": 5
        },
        "explanation": "3 is smaller than 5. New smallest.",
        "stats": {
          "comparisons": 14,
          "swaps": 2
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 5
          }
        ],
        "highlights": [
          {
            "index": 5,
            "role": "pivot"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          }
        ],
        "codeLine": 6,
        "variables": {
          "i": 2,
          "j": 5,
          "min": 5,
          "smallestSoFar": 3
        },
        "explanation": "Remember position 5. 3 is the smallest we've seen so far.",
        "stats": {
          "comparisons": 14,
          "swaps": 2
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 5
          },
          {
            "name": "j",
            "index": 6
          }
        ],
        "highlights": [
          {
            "index": 5,
            "role": "pivot"
          },
          {
            "index": 6,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 2,
          "j": 6,
          "min": 5,
          "smallestSoFar": 3
        },
        "explanation": "7 is not smaller than 3. Keep looking.",
        "stats": {
          "comparisons": 15,
          "swaps": 2
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 2,
            "role": "swap"
          },
          {
            "index": 5,
            "role": "swap"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          }
        ],
        "codeLine": 10,
        "variables": {
          "i": 2,
          "min": 5,
          "swaps": 3
        },
        "explanation": "3 is the winner, so swap it into position 2. 5 takes its old seat.",
        "stats": {
          "comparisons": 15,
          "swaps": 3
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          }
        ],
        "codeLine": 2,
        "variables": {
          "i": 2,
          "swaps": 3
        },
        "explanation": "3 is locked in at position 2. It will never move again.",
        "stats": {
          "comparisons": 15,
          "swaps": 3
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 3
          }
        ],
        "highlights": [
          {
            "index": 3,
            "role": "active"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          }
        ],
        "codeLine": 3,
        "variables": {
          "i": 3,
          "min": 3,
          "smallestSoFar": 8
        },
        "explanation": "Start of pass 4. Assume 8 is the smallest thing left, then try to prove yourself wrong.",
        "stats": {
          "comparisons": 15,
          "swaps": 3
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 3
          },
          {
            "name": "j",
            "index": 4
          }
        ],
        "highlights": [
          {
            "index": 3,
            "role": "pivot"
          },
          {
            "index": 4,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 3,
          "j": 4,
          "min": 3,
          "smallestSoFar": 8
        },
        "explanation": "9 is not smaller than 8. Keep looking.",
        "stats": {
          "comparisons": 16,
          "swaps": 3
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 3
          },
          {
            "name": "j",
            "index": 5
          }
        ],
        "highlights": [
          {
            "index": 3,
            "role": "pivot"
          },
          {
            "index": 5,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 3,
          "j": 5,
          "min": 3,
          "smallestSoFar": 8
        },
        "explanation": "5 is smaller than 8. New smallest.",
        "stats": {
          "comparisons": 17,
          "swaps": 3
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 5
          }
        ],
        "highlights": [
          {
            "index": 5,
            "role": "pivot"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          }
        ],
        "codeLine": 6,
        "variables": {
          "i": 3,
          "j": 5,
          "min": 5,
          "smallestSoFar": 5
        },
        "explanation": "Remember position 5. 5 is the smallest we've seen so far.",
        "stats": {
          "comparisons": 17,
          "swaps": 3
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 5
          },
          {
            "name": "j",
            "index": 6
          }
        ],
        "highlights": [
          {
            "index": 5,
            "role": "pivot"
          },
          {
            "index": 6,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 3,
          "j": 6,
          "min": 5,
          "smallestSoFar": 5
        },
        "explanation": "7 is not smaller than 5. Keep looking.",
        "stats": {
          "comparisons": 18,
          "swaps": 3
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 3,
            "role": "swap"
          },
          {
            "index": 5,
            "role": "swap"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          }
        ],
        "codeLine": 10,
        "variables": {
          "i": 3,
          "min": 5,
          "swaps": 4
        },
        "explanation": "5 is the winner, so swap it into position 3. 8 takes its old seat.",
        "stats": {
          "comparisons": 18,
          "swaps": 4
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          }
        ],
        "codeLine": 2,
        "variables": {
          "i": 3,
          "swaps": 4
        },
        "explanation": "5 is locked in at position 3. It will never move again.",
        "stats": {
          "comparisons": 18,
          "swaps": 4
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 4
          }
        ],
        "highlights": [
          {
            "index": 4,
            "role": "active"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          }
        ],
        "codeLine": 3,
        "variables": {
          "i": 4,
          "min": 4,
          "smallestSoFar": 9
        },
        "explanation": "Start of pass 5. Assume 9 is the smallest thing left, then try to prove yourself wrong.",
        "stats": {
          "comparisons": 18,
          "swaps": 4
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 4
          },
          {
            "name": "j",
            "index": 5
          }
        ],
        "highlights": [
          {
            "index": 4,
            "role": "pivot"
          },
          {
            "index": 5,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 4,
          "j": 5,
          "min": 4,
          "smallestSoFar": 9
        },
        "explanation": "8 is smaller than 9. New smallest.",
        "stats": {
          "comparisons": 19,
          "swaps": 4
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 5
          }
        ],
        "highlights": [
          {
            "index": 5,
            "role": "pivot"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          }
        ],
        "codeLine": 6,
        "variables": {
          "i": 4,
          "j": 5,
          "min": 5,
          "smallestSoFar": 8
        },
        "explanation": "Remember position 5. 8 is the smallest we've seen so far.",
        "stats": {
          "comparisons": 19,
          "swaps": 4
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 5
          },
          {
            "name": "j",
            "index": 6
          }
        ],
        "highlights": [
          {
            "index": 5,
            "role": "pivot"
          },
          {
            "index": 6,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 4,
          "j": 6,
          "min": 5,
          "smallestSoFar": 8
        },
        "explanation": "7 is smaller than 8. New smallest.",
        "stats": {
          "comparisons": 20,
          "swaps": 4
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c4-9",
            "value": 9
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c6-7",
            "value": 7
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 6
          }
        ],
        "highlights": [
          {
            "index": 6,
            "role": "pivot"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          }
        ],
        "codeLine": 6,
        "variables": {
          "i": 4,
          "j": 6,
          "min": 6,
          "smallestSoFar": 7
        },
        "explanation": "Remember position 6. 7 is the smallest we've seen so far.",
        "stats": {
          "comparisons": 20,
          "swaps": 4
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 4,
            "role": "swap"
          },
          {
            "index": 6,
            "role": "swap"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          }
        ],
        "codeLine": 10,
        "variables": {
          "i": 4,
          "min": 6,
          "swaps": 5
        },
        "explanation": "7 is the winner, so swap it into position 4. 9 takes its old seat.",
        "stats": {
          "comparisons": 20,
          "swaps": 5
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          },
          {
            "index": 4,
            "role": "sorted"
          }
        ],
        "codeLine": 2,
        "variables": {
          "i": 4,
          "swaps": 5
        },
        "explanation": "7 is locked in at position 4. It will never move again.",
        "stats": {
          "comparisons": 20,
          "swaps": 5
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 5
          }
        ],
        "highlights": [
          {
            "index": 5,
            "role": "active"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          },
          {
            "index": 4,
            "role": "sorted"
          }
        ],
        "codeLine": 3,
        "variables": {
          "i": 5,
          "min": 5,
          "smallestSoFar": 8
        },
        "explanation": "Start of pass 6. Assume 8 is the smallest thing left, then try to prove yourself wrong.",
        "stats": {
          "comparisons": 20,
          "swaps": 5
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          }
        ],
        "pointers": [
          {
            "name": "min",
            "index": 5
          },
          {
            "name": "j",
            "index": 6
          }
        ],
        "highlights": [
          {
            "index": 5,
            "role": "pivot"
          },
          {
            "index": 6,
            "role": "compare"
          },
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          },
          {
            "index": 4,
            "role": "sorted"
          }
        ],
        "codeLine": 5,
        "variables": {
          "i": 5,
          "j": 6,
          "min": 5,
          "smallestSoFar": 8
        },
        "explanation": "9 is not smaller than 8. Keep looking.",
        "stats": {
          "comparisons": 21,
          "swaps": 5
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          },
          {
            "index": 4,
            "role": "sorted"
          },
          {
            "index": 5,
            "role": "sorted"
          }
        ],
        "codeLine": 2,
        "variables": {
          "i": 5,
          "swaps": 5
        },
        "explanation": "8 is locked in at position 5. It will never move again.",
        "stats": {
          "comparisons": 21,
          "swaps": 5
        }
      },
      {
        "data": [
          {
            "id": "c3-1",
            "value": 1
          },
          {
            "id": "c5-2",
            "value": 2
          },
          {
            "id": "c1-3",
            "value": 3
          },
          {
            "id": "c2-5",
            "value": 5
          },
          {
            "id": "c6-7",
            "value": 7
          },
          {
            "id": "c0-8",
            "value": 8
          },
          {
            "id": "c4-9",
            "value": 9
          }
        ],
        "pointers": [],
        "highlights": [
          {
            "index": 0,
            "role": "sorted"
          },
          {
            "index": 1,
            "role": "sorted"
          },
          {
            "index": 2,
            "role": "sorted"
          },
          {
            "index": 3,
            "role": "sorted"
          },
          {
            "index": 4,
            "role": "sorted"
          },
          {
            "index": 5,
            "role": "sorted"
          },
          {
            "index": 6,
            "role": "sorted"
          }
        ],
        "codeLine": 13,
        "variables": {
          "comparisons": 21,
          "swaps": 5
        },
        "explanation": "Done. Notice how few swaps that took: 5. Selection sort is lazy about moving things.",
        "stats": {
          "comparisons": 21,
          "swaps": 5
        }
      }
    ]
  }
}