Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/menud/array.rb
Instance Method Summary collapse
Instance Method Details
#bubbleach ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/menud/array.rb', line 29 def bubbleach cent = true self.each_index do |i| cent = false self.each_index do |j| if self[i] < self[j] self[i], self[j] = self[j], self[i] cent=true end end break if cent == false end self end |
#bubblefor ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/menud/array.rb', line 4 def bubblefor cent = true for i in 0...(self.length-1) cent = false for j in 0...(self.length-i-1) if self[j] > self[j+1] self[j],self[j+1]=self[j+1],self[j] cent=true end end break if cent == false end self end |