Win32ole object collection mapping to array ?

P

Peter Fitzgibbons

------_=_NextPart_001_01C5A98D.453C8238
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hello all,

I have a win32ole object collection that I want to map, then sort, to an
array?

Each item has #Name property. I'm thinking of making an arry of hashes
a'la :
items =3D []
oleItems.each {|o| items << {o.Name =3D> o} }
items
[{"0172"=3D>#<WIN32OLE:0x2a88570>}, {"0171"=3D>#<WIN32OLE:0x2a88540>}]

But then, how do I sort the array of hashes ?

Is there a better approach ?

Peter J. Fitzgibbons
Applications Manager
Lakewood Homes - "The American Dream Builder"(r)
(e-mail address removed)
(847) 884-8800=20



------_=_NextPart_001_01C5A98D.453C8238--
 
B

Brian Takita

------=_Part_6061_9944935.1124997093782
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Sorry. What I gave you is wrong. Daniel has a good solution.

=20
Try this...
=20
items =3D []
oleItems.each {|o| items << {o.Name =3D> o} }
items.sort {|x, y| x.Name <=3D> y.Name} =20

=20
Hello all,
=20
I have a win32ole object collection that I want to map, then sort, to a= n=20
=20
array?
=20
Each item has #Name property. I'm thinking of making an arry of hashes
a'la :
=20
items =3D []
oleItems.each {|o| items << {o.Name =3D> o} }
items
[{"0172"=3D>#<WIN32OLE:0x2a88570>}, {"0171"=3D>#<WIN32OLE:0x2a88540>}]= =20
=20
But then, how do I sort the array of hashes ?
=20
Is there a better approach ?
=20
Peter J. Fitzgibbons
Applications Manager
Lakewood Homes - "The American Dream Builder"(r)
(e-mail address removed)
(847) 884-8800
=20
=20
=20
=20

------=_Part_6061_9944935.1124997093782--
 
T

tokmak tokmak

------=_Part_1030_8826167.1125485053650
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

You can try this (apologies if i misunderstood you problem):

oleitems.map{|o| o.Name}.sort

This makes an array of Name values, then sorts it. I couldn't understand if=
=20
you want values as an array or hash.

=20
Hello all,
=20
I have a win32ole object collection that I want to map, then sort, to an
array?
=20
Each item has #Name property. I'm thinking of making an arry of hashes
a'la :
=20
items =3D []
oleItems.each {|o| items << {o.Name =3D> o} }
items
[{"0172"=3D>#<WIN32OLE:0x2a88570>}, {"0171"=3D>#<WIN32OLE:0x2a88540>}]
=20
But then, how do I sort the array of hashes ?
=20
Is there a better approach ?
=20
Peter J. Fitzgibbons
Applications Manager
Lakewood Homes - "The American Dream Builder"(r)
(e-mail address removed)
(847) 884-8800
=20
=20
=20

------=_Part_1030_8826167.1125485053650--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top