Module: Enumerable
- Defined in:
- lib/smoothsort.rb,
ext/smoothsort/smoothsort.c
Instance Method Summary collapse
-
#ssort ⇒ Array
Returns an array containing the items in enum sorted, according to their own <=> method, using the smoothsort algorithm.
-
#ssort! ⇒ Array
Sorts an array in-place using the smoothsort algorithm.
Instance Method Details
#ssort ⇒ Array
Returns an array containing the items in enum sorted, according to their own <=> method, using the smoothsort algorithm
9 10 11 12 13 |
# File 'lib/smoothsort.rb', line 9 def ssort a = self.clone a.ssort! a end |
#ssort! ⇒ Array
Sorts an array in-place using the smoothsort algorithm
158 159 160 161 162 |
# File 'ext/smoothsort/smoothsort.c', line 158 static VALUE smoothsort_ssort_bang(VALUE self) { //return RTEST(rb_funcall(rb_ary_entry(self, 0), rb_intern("<="), 1, rb_ary_entry(self, 1))) ? Qtrue : Qfalse; smoothsort(self, (int)RARRAY_LEN(self)); return self; } |