SnowArraySort 1.0.15 → 1.0.16
Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@ module SnowArraySort
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.mergesort(container)
|
17
|
-
return container if container.size
|
17
|
+
return container if (container.size <= 1)
|
18
18
|
mid = container.size / 2
|
19
19
|
left = container[0...mid]
|
20
20
|
right = container[mid...container.size]
|
@@ -24,7 +24,7 @@ module SnowArraySort
|
|
24
24
|
def self.merge(left, right)
|
25
25
|
sorted = []
|
26
26
|
until left.empty? or right.empty?
|
27
|
-
left.first <= right.first ? sorted << left.shift : sorted << right.shift
|
27
|
+
(left.first <= right.first) ? sorted << left.shift : sorted << right.shift
|
28
28
|
end
|
29
29
|
sorted + left + right
|
30
30
|
end
|