From: Robert Evans Date: 2004-10-06T16:43:05+09:00 Subject: Fixnum <=> confusion Hi, I am recently learning Ruby, and came across an interesting problem that I do not understand. I was trying to count how many times the sort method was called on an object by overridding <=> to count the number of calls. I decided to extend Fixnum as follows, but it didn't work. Can anyone tell me why? Thanks. Bob Evans Code: class Fixnum @@count = 0 alias originalComparator <=> def <=>(o) @@count += 1 originalComparator(o) end def Fixnum.count @@count end end Running against it: >array = [5, 4, 3, 2, 1] => [5,4,3,2,1] >array.sort => [1,2,3,4,5] >Integer.count => 0 Expected => 6 > result > 0 Now, if I call 1<=>2 then count increments. Does this mean that Fixnum sorting does not call those operators? Thanks for any help.