SnowArraySort 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # SnowArraySort
2
+ Algorithm's for sorting array's
@@ -0,0 +1,10 @@
1
+ module SnowArraySort
2
+ class SnowAD
3
+ include SnowArraySort
4
+ def <=>(entries)
5
+ -super
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,39 @@
1
+ module SnowArraySort
2
+ class MASort
3
+ include SnowArraySort
4
+
5
+ def mergesort(array)
6
+ def merge(left_sorted, right_sorted)
7
+ res = []
8
+ l = 0
9
+ r = 0
10
+
11
+ loop do
12
+ break if r >= right_sorted.length and l >= left_sorted.length
13
+
14
+ if r >= right_sorted.length or (l < left_sorted.length and left_sorted[l] < right_sorted[r])
15
+ res << left_sorted[l]
16
+ l += 1
17
+ else
18
+ res << right_sorted[r]
19
+ r += 1
20
+ end
21
+ end
22
+
23
+ return res
24
+ end
25
+
26
+ def mergesort_iter(array_sliced)
27
+ return array_sliced if array_sliced.length <= 1
28
+
29
+ mid = array_sliced.length/2 - 1
30
+ left_sorted = mergesort_iter(array_sliced[0..mid])
31
+ right_sorted = mergesort_iter(array_sliced[mid+1..-1])
32
+ return merge(left_sorted, right_sorted)
33
+ end
34
+
35
+ mergesort_iter(array)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,4 @@
1
+ module SnowArraySort
2
+ VERSION = "1.0.1"
3
+ end
4
+
@@ -0,0 +1,8 @@
1
+ require "SnowArraySort/version"
2
+ require "SnowArraySort/merge_array_sort_snow"
3
+ require 'SnowArraySort/asc_desc_array_sort_snow'
4
+
5
+
6
+ module SnowArraySort
7
+
8
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: SnowArraySort
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Justin Snow
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-11-09 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Support for asc and desc order on multiple array fields also added ability
15
+ to merge sort as well.
16
+ email:
17
+ - jrsnow8921@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - README.md
23
+ - Gemfile
24
+ - lib/SnowArraySort/merge_array_sort_snow.rb
25
+ - lib/SnowArraySort/version.rb
26
+ - lib/SnowArraySort/asc_desc_array_sort_snow.rb
27
+ - lib/SnowArraySort.rb
28
+ homepage: https://github.com/Jrsnow8921/SnowArraySort
29
+ licenses:
30
+ - MIT
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.23.2
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: Algorithms for sorting arrays
53
+ test_files: []