def ordering(mods)
a = mods.permutation(2)
.select { |m1,m2| (m1<=>m2) == -1 }
a.reject { |m1,m2|
mods.any? { |m| a.include?([m1,m]) && a.include?([m,m2]) } }
end
ordering([Object, Comparable, Float, Fixnum, Integer])
#=> [[Float, Object],
# [Float, Comparable],
# [Fixnum, Integer],
# [Integer, Object],
# [Integer, Comparable]]
mods = [Object, Comparable, Float, Fixnum, Integer, String, Array,
Hash, Enumerable, Enumerator, Module, Method, IO, File]
ordering(mods)
#=> [[Float, Object], [Float, Comparable],
# [Fixnum, Integer],
# [Integer, Object], [Integer, Comparable],
# [String, Object], [String, Comparable],
# [Array, Object], [Array, Enumerable],
# [Hash, Object], [Hash, Enumerable], [Hash, Object],
# [Hash, Enumerable],
# [Enumerator, Object], [Enumerator, Enumerable],
# [Module, Object],
# [Method, Object],
# [IO, Object], [IO, Enumerable],
# [File, IO]]