mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 18:32:20 +08:00
24 lines
417 B
CoffeeScript
24 lines
417 B
CoffeeScript
|
class quicksort
|
||
|
sort: (items) ->
|
||
|
return items if items.length <= 1
|
||
|
|
||
|
pivot = items.shift()
|
||
|
left = []
|
||
|
right = []
|
||
|
|
||
|
# Comment in the middle
|
||
|
|
||
|
while items.length > 0
|
||
|
current = items.shift()
|
||
|
if current < pivot
|
||
|
left.push(current)
|
||
|
else
|
||
|
right.push(current);
|
||
|
|
||
|
sort(left).concat(pivot).concat(sort(right))
|
||
|
|
||
|
noop: ->
|
||
|
# just a noop
|
||
|
|
||
|
exports.modules = quicksort
|