SnowArraySort 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
|