From: Ehsanul Hoque Date: 2009-09-22T03:18:26+09:00 Subject: Re: Hash or array? --_7fbce53f-74ae-46fa-b22a-02ef2b65da5f_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable >=20 > I have a question=2C I want to store some data in two columns=2C for exam= ple >=20 > 0001=2C stuff1 stuff2 > 0002=2C morestuff > 0003=2C extrastuff > 0004=2C more evenmore >=20 > As you can see column 1 is an ID and column 2 is one or more strings. >=20 > I want to do a search across another data set to say if column 1 (ID > number) matches in both sets and the contents of column 2 to data set B. >=20 > I initially thought to use a hash=2C but it scrambles the order of the > data so was unsure of its efficiency and use. >=20 > Any suggestions? Since everybody else is rooting for hashes=2C let's talk arrays. You could = use a structure like this: mydata =3D [nil=2C [stuff1=2C stuff2]=2C [morestuff]=2C [extrastruff]=2C [m= ore evenmore]] Then to search for matches=2C you can do: searched1 =3D mydata[1] & datasetA & datasetB searched2 =3D mydata[2] & datasetB This is assuming that your datasets are arrays of course. And it's fine if you want to use hashes to store the key as id too: mydata =3D{ 1 =3D> [stuff1=2C stuff2]=2C 2 =3D>[morestuff]=2C 3 =3D> [extra= struff]=2C 4 =3D>[more evenmore] } searched1 =3D mydata[1] & datasetA & datasetB searched2 =3D mydata[2] & datasetB =0A= _________________________________________________________________=0A= Lauren found her dream laptop. Find the PC that=92s right for you.=0A= http://www.microsoft.com/windows/choosepc/?ocid=3Dftp_val_wl_290= --_7fbce53f-74ae-46fa-b22a-02ef2b65da5f_--