I can only answer a few of your questions:

jmichel / schur.institut.math.jussieu.fr (Jean Michel) writes:

|   - I had trouble using sort! in method-chaining because
| 
|     irb(main):006:0> [1,2].sort!
|     [1, 2]
|     irb(main):007:0> [1].sort!
|     nil
| 
|     the reason why sort! does not return its result for arrays of length
|     1 eludes me.

sort! returns whether the array had to be sorted (which means true
for arrays of length >= 2, false otherwise).  This was discussed
recently in comp.lang.ruby and it seemed that most people regard it
as a misfeature.  I don't remember if there were any plans to change
it.

|   - In perl, if one wants to sort according to several criteria, one can
|     write something like that
| 
|       sort { length($a) <=> length($b) or $a cmp $b }
| 
|     this does not work in ruby since 'or' behaves completely different --
|     it can apparently be used only in a very restricted way in boolean
|     expressions. The closest I could come with is:
| 
|       sort {|a,b|  [a.length,a]<=>[b.length,b]}
| 
|     but  it does  not have  the same  effect as  the perl  idiom not  to
|     evaluate the second sort criterion when the first suffices.

0 is true in Ruby, so you have to convert 0 to nil using the
nonzero? method of Numeric:

  sort { (a.length <=> b.length).nonzero? || a <=> b }

|   - I was very surprised that  each_pair is not defined for arrays, only
|     hashes. Of course you can roll your own:
| 
|      class Array  
|        def each_pair 
|          each_index do |i| yield(i,self[i]) end
|        end 
|      end
| 
|     but why is such an essential idiom not pre-defined?

It's called each_with_index, found in Enumerable.

-- 
http://www.dfan.org