arrays in awk???

Been struggling with a problem, I have been trying to do this in awk, but am unable to figure this out, I think arrays have to be used, but unsure how to accomplish this.

I have a input file that looks like this:

141;ny;y;g
789;ct;e;e
23;ny;n;u
45;nj;e;u
216;ny;y;u
7;ny;e;e
1456;ny;e;g
2;ct;n;e

I want the output to look like this:

ny: 141 23 216 7 1456
ct: 789 2
nj: 45

Is this possible? I know it is, but I can't figure it out, would like to use awk if possible.

thanks in advance.

You can do something like that :

awk -F';' '
   {
      array[$2] = array[$2] " " $1;
   }
   END {
      for (i in array)
         print i ":" array;
   }
   ' inputfile

Jean-Pierre.

aigles,

array[$2] = ($2 in array[$2]) ? array[$2] " " $1 : $1;

thanks much, that did it!!!!