Sort on two arrays
class MultiArray
include Enumerable
def initialize(*arrays)
@arrays = arrays
end
def each
@arrays.each { |a| a.each { |x| yield x } }
end
end
ma = MultiArray.new([1, 2], [3], [4])
ma.sort # => [1, 2, 3, 4]
mixed_type_ma = MultiArray.new([1, 2, 3], ["a", "b", "c"])
mixed_type_ma.sort
# ArgumentError: comparison of Fixnum with String failed
Related examples in the same category