471,896 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,896 software developers and data experts.

Grouping Arrays with same initial values

I have a new question about organizing multidimensional arrays.
I have an array containing several others; my aim is to obtain a new array, which groups together those arrays from the first array that share the same initial value ("00527-00527.tif" in this case).

Here's my code:

startingGroup = new Array(); //starting array
startingGroup[0] = ["00527-00527.tif;00527;Product_1;33;25,13"];
startingGroup[1] = ["00527-00527.tif;00528;Product_2;33;25,13"];
startingGroup[2] = ["01211-01211.tif;00119;Product_3;26;25,06"];

//I want to obtain this
resultingGroup = new Array(); //resulting array
resultingGroup[0] = ["00527-00527.tif;00527;Product_1;33;25,13","00527-00527.tif;00528;Product_2;33;25,13"];
resultingGroup[1] = ["01211-01211.tif;00119;Product_3;26;25,06"];[/HTML]

I wonder if is it possible to do it so

Any help would be mouch appreciated

Nov 16 '08 #1
1 1427
16,027 Expert Mod 8TB
You could use a temporary array to store the initial values. How would you determine an initial value? Is it till the semi-colon? Use a regular expression to test if the initial string matches.

Use concat() to combine arrays.
Nov 17 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by csx | last post: by
50 posts views Thread by SABmore | last post: by
6 posts views Thread by Xiaozhu | last post: by
4 posts views Thread by thehuby | last post: by
197 posts views Thread by Steve Kobes | last post: by
41 posts views Thread by Rene Nyffenegger | last post: by
4 posts views Thread by mantrid | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.