       j = Math.floor(Math.random() * (i+1))
       [@values[i], @values[j]] = [@values[j], @values[i]]
 
+  ###
+  # Sort the array (not visual).
+  ###
   sort: =>
     @values.sort (a, b) => a.value - b.value
 
+  ###
+  # Reverse the array (not visual).
+  ###
   reverse: =>
     @values.reverse()
 
+  ###
+  # Push a step onto the animation queue; adds the keys expected on every step.
+  # @param {map} dict The map to push onto the animation queue.
+  ###
   animationQueuePush: (dict) =>
     dict.swaps = @swaps
     dict.inserts = @inserts

    for indice, i in indices
      throw new Error("#{methodName}, argument #{i+1} : #{indice} is not a valid index") if not (0 <= indice < @values.length)

  swap: (i, j) =>
    @checkIndexes("swap", [i, j])
    @swaps++
    if i == j
      return
    @animationQueuePush(type: "swap", i: i, j: j)
    [@values[i], @values[j]] = [@values[j], @values[i]]

  insert: (i, j) =>
    @checkIndexes("insert", [i, j])
    @inserts++
    @shifts += Math.abs(j - i)
    if i == j
      return
    @animationQueuePush(type: "insert", i: i, j: j)

    @checkIndexes("eq", [i, j])
    @compares++
    @animationQueuePush(type: "compare", i: i, j: j)
    @get(i) == @get(j)

  neq: (i, j) =>
    @checkIndexes("neq", [i, j])
    @compares++
    @animationQueuePush(type: "compare", i: i, j: j)
    @get(i) != @get(j)

  lt: (i, j) =>
    @checkIndexes("lt", [i, j])
    @compares++
    @animationQueuePush(type: "compare", i: i, j: j)
    @get(i) < @get(j)

  gt: (i, j) =>
    @checkIndexes("gt", [i, j])
    @compares++
    @animationQueuePush(type: "compare", i: i, j: j)
    @get(i) > @get(j)

  lte: (i, j) =>
    @checkIndexes("lte", [i, j])
    @compares++
    @animationQueuePush(type: "compare", i: i, j: j)
    @get(i) <= @get(j)

  gte: (i, j) =>
    @checkIndexes("gte", [i, j])
    @compares++
    @animationQueuePush(type: "compare", i: i, j: j)
    @get(i) >= @get(j)

  highlight: (indices) =>
    if !$.isArray indices
