From: Paul Lutus Date: 2006-12-03T19:45:05+09:00 Subject: Re: can't sort an array chen li wrote: > Hi all, > > I want to print all the methods in excel OLE object > in alphabetic order but the sort method is > unavailable. Can anyone explain it and help me fix it? > > Thank you, > > Li > ## > require 'win32ole' > excel = WIN32OLE.new('Excel.Application') > m = excel.ole_methods > p m.class > p m.sort > > ##screen output >>ruby sort1.rb > Array > sort1.rb:6:in `sort': undefined method `<=>' for > Rows:WIN32OLE_METHOD (NoMethodError) > from sort1.rb:6 >>Exit code: 1 One solution is to convert the entire OLE data array into an equivalent Ruby type, such as an array of Ruby strings, and sort those. In this case, you could take the "excel.ole_methods" list and insert it into a Ruby array, hopefully as strings, and sort the resulting array. -- Paul Lutus http://www.arachnoid.com