Hal Fulton wrote:
> Patrick Hurley wrote:
> 
>>
>>> 2. Further I believe that such an algorithm could be used
>>> to implement multi-key sorts as "chained" sorts -- correct?
>>>      people.sort(:name).sort(:age).sort(:height)
>>
>>
>> Sure, but I am guessing you would want to reverse the order of the 
>> sorting.
> 
> 
> Yes, I see what you mean.
> 
>>> Given that, what is a good stable sort algorithm? Would
>>> it be too inefficient to implement in Ruby or no?
>>
>>
>> Mergesort is a good choice. Efficency should be reasonable depending
>> upon data set sizes. Therea re of course other possiblities. When in
>> doubt:
>>
>> D. E. Knuth. The Art of Computer Programming, Volume 3: Sorting and
>> Searching. Addison-Wesley, Reading MA, 1973.
> 
> 
> Yes... I always had one handy, but now I don't. I should actually
> buy one.
> 
> Anyone ever implemented mergesort in Ruby? Got one handy?

Looks like the invaluable Bruno R Preiss has quite a few algorithms
in his back pocket: http://www.brpreiss.com/books/opus8/programs/

> Hal

E