Columns to Rows

I want to create a script with gawk.

I have the following file with 2 columns:

A 1 
A 2
A 3
B 1
B 2
B 3
C 1
C 2
D 1
D 2
D 3
D 4

and i want to convert to:

A 1 2 3
B 1 2 3 
C 1 2
D 1 2 3 4

Thanks in advance.

BR,
Sameer

Hi

$ gawk '$1==x{y=y FS $2;next}{if(y)print y;x=$1;y=$1 FS $2;}END{print y;}' file
A 1 2 3
B 1 2 3
C 1 2
D 1 2 3 4