       @ctx.fillStyle = @colors.insert
       @drawIndex(step.i)
       setTimeout =>
-        if step.i < step.j
-          [@animationValues[step.j], @animationValues[step.i...step.j]] = [@animationValues[step.i], @animationValues[step.i+1..step.j]]
-          [@animationIndices[step.j], @animationIndices[step.i...step.j]] = [@animationIndices[step.i], @animationIndices[step.i+1..step.j]]
-        else
-          [@animationValues[step.j], @animationValues[step.j+1..step.i]] = [@animationValues[step.i], @animationValues[step.j...step.i]]
-          [@animationIndices[step.j], @animationIndices[step.j+1..step.i]] = [@animationIndices[step.i], @animationIndices[step.j...step.i]]
+        [tmp] = @animationValues.splice step.i, 1
+        @animationValues.splice step.j, 0, tmp
+        [tmp] = @animationIndices.splice step.i, 1
+        @animationIndices.splice step.j, 0, tmp
         @redraw()
         @ctx.fillStyle = @colors.slide
         for x in slideRange

    if i == j
      return
    @animationQueuePush(type: "insert", i: i, j: j)
    if i < j
      [@values[j], @values[i...j]] = [@values[i], @values[i+1..j]]
      [@indices[j], @indices[i...j]] = [@indices[i], @indices[i+1..j]]
    else
      [@values[j], @values[j+1..i]] = [@values[i], @values[j...i]]
      [@indices[j], @indices[j+1..i]] = [@indices[i], @indices[j...i]]
  
  eq: (i, j) =>
    @compares++

  return

$("#js-quick-highlight").click ->
  VA.quickHighlight = $("#js-quick-highlight").is(":checked")
  return

$("#js-quick-compare").click ->
  VA.quickCompare = $("#js-quick-compare").is(":checked")
  return

$(".js-show-sort").click (e) ->
