News for hackers. Stuff that matters.
Re:Show HN: Write a sort, watch it go by dhathorn on Monday September 26, 2011 @11:40PM (#3041762)
Cocktail sort

  twoWayBubbleSort = ->
    VA.locals.swapped = true
    while VA.locals.swapped
      VA.locals.swapped = false
      for x in [0...VA.length - 1]
        VA.locals.x = x
        if VA.gt(x, x + 1)
          VA.swap(x, x + 1)
          VA.locals.swapped = true
      for x in[(VA.length-1)..1]
        VA.locals.x = x
        if VA.gt(x - 1, x)
          VA.swap(x - 1, x)
          VA.locals.swapped = true


  twoWayBubbleSort()

There are no comments on this comment yet.