     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]]
+    [tmp] = @values.splice i, 1
+    @values.splice j, 0, tmp
+    [tmp] = @indices.splice i, 1
+    @indices.splice j, 0, tmp
   
   eq: (i, j) =>
     @compares++

  return

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

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

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

      [@indices[i], @indices[j]] = [@indices[j], @indices[i]]

  sort: =>
    @values.sort (a, b) => a - b
    @indices.sort (a, b) => a - b

  reverse: =>
    @values.reverse()
    @indices.reverse()

  animationQueuePush: (dict) =>
    dict.swaps = @swaps
