file formatiing with awk ?

Hi friends,

I have to change the file format. I am fighting with writing a script with awk to do it. My input file format is as follows,

AAA 123
AAA 200
BBB 320
BBB 400
CCC 120
CCC 460

I want to change it a following format,

AAA 123 200
BBB 320 400
CCC 120 460

Can somebody tell me how can I uses sed command to do this.

Thanking you,
Mahesh Fernando.

awk '{ arr[$1] = arr[$1]$2" " } END { for (a in arr) { print a,arr[a]} }' file

Hi friend,

Thank for the help.

It is working fine.
If possibel please explain me how this work.

Thanks,
Mahesh Fernando.