Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jan 18, 2019. It is now read-only.

Latest commit

 

History

History
History
31 lines (25 loc) · 672 Bytes

File metadata and controls

31 lines (25 loc) · 672 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class SortAlgorithm
bubbleSort: (nums) ->
_nums = nums[..]
for i in [0.._nums.length]
for j in [i + 1.._nums.length]
if _nums[i] > _nums[j]
[_nums[i], _nums[j]] = [_nums[j], _nums[i]]
_nums
quickSort: (nums) ->
_nums = nums[..]
if _nums.length < 1
return _nums
pi = _nums[0]
left = []
right = []
for i in _nums[1..]
if i < pi
left.push(i)
else
right.push(i)
@quickSort(left).concat([pi]).concat(@quickSort(right))
sort = new SortAlgorithm
nums = (Math.floor(Math.random() * 10) for i in [0...10])
console.log sort.bubbleSort(nums)
console.log sort.quickSort(nums)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.