old/lib/RubyExt/array.rb in ruby-ext-0.2.16 vs old/lib/RubyExt/array.rb in ruby-ext-0.4.0
- old
+ new
@@ -1,24 +1,24 @@
class Array
- def sort_by_weight weight
- clone.sort_by_weight! weight.clone
- end
-
- def sort_by_weight! weight
- size.times do |i|
- iteration = size - i - 1
- break if iteration < 0
- iteration.times do |j|
- if weight[j] > weight[j+1]
- buf = self[j]
- self[j] = self[j+1]
- self[j+1] = buf
-
- buf = weight[j]
- weight[j] = weight[j+1]
- weight[j+1] = buf
- end
- end
- end
- return self
- end
+ def sort_by_weight weight
+ clone.sort_by_weight! weight.clone
+ end
+
+ def sort_by_weight! weight
+ size.times do |i|
+ iteration = size - i - 1
+ break if iteration < 0
+ iteration.times do |j|
+ if weight[j] > weight[j+1]
+ buf = self[j]
+ self[j] = self[j+1]
+ self[j+1] = buf
+
+ buf = weight[j]
+ weight[j] = weight[j+1]
+ weight[j+1] = buf
+ end
+ end
+ end
+ return self
+ end
end
\ No newline at end of file