dynamic values in a row

hi
i have an input file in which there are diffrent values for xxxx,yyyyyy,zzzzzzz how can i arrange the dynamic values of x,y&z in a row.

input file:

xxxxx 1
yyyyyy 4
yyyyyy 5
zzzzzzzz 7
yyyyyy 13
zzzzzzzz 7
zzzzzzzz 6
yyyyyy 14
yyyyyy 12
zzzzzzzz 4
yyyyyy 4
yyyyyy 5
yyyyyy 6
yyyyyy 15
yyyyyy 7
zzzzzzzz 12
zzzzzzzz 14
zzzzzzzz 13
zzzzzzzz 15
zzzzzzzz 5
xxxxx 1

output:

xxxxx 1,1
yyyyyy 4,14,5,6,15
zzzzzzzz7,7,6,4,12,14,15

I do not understand the logic:

grep y infile| cut -d" " -f2| sort -nu
4
5
6
7
12
13
14
15

There seem to be missing values.

Anyway maybe this is what you are looking for:

$> awk '{_[$1] ? _[$1]= _[$1] OFS $2 : _[$1]= $2} END{for(a in _){print a " " _[a]}}' OFS=, infile
yyyyyy 4,5,13,14,12,4,5,6,15,7
xxxxx 1,1
zzzzzzzz 7,7,6,4,12,14,13,15,5

it gave me output:

,55zzz 7
,75yyy 4
,1xxxx 1

please suggest:

What OS are you using?

its sun solaris 5.9

---------- Post updated at 09:35 PM ---------- Previous update was at 09:35 PM ----------

i need it urgently ... plz help

Use nawk and try if solaris.

[root@bt] $ uname -a
SunOS 5.8 xxxxxxxxxxxxxxxxxxx
[root@bt]  $ nawk '{_[$1] ? _[$1]= _[$1] OFS $2 : _[$1]= $2} END{for(a in _){print a " " _[a]}}' OFS=, f
xxxxx 1,1
yyyyyy 4,5,13,14,12,4,5,6,15,7
zzzzzzzz 7,7,6,4,12,14,13,15,5

--ahamed