Getting most repeated 3 lines

Hi all
if i want to get the 3 lines of the most repeated lines here

tony,1,x
tony,1,x
tony,2,x
tony,2,x
tony,3,x
tony,4,x
tony,5,x
adam,1,y

to get output

tony,1,x
tony,2,x
tony3,x
adam,1,y
ive tried to uniq -c | /usr/xpg4/bin/awk -F"," '!a[$1]++'  

but it gets only first one i need first 3

I am unable to understand your full requirement..
what does this mean? "3 lines of the most repeated lines "
why out of three lines below u selected tony3,x?
tony,3,x
tony,4,x
tony,5,x

Hi,

This can help you,

 cat file1
tony,1,x
tony,1,x
tony,2,x
tony,2,x
tony,3,x
tony,4,x
tony,5,x
adam,1,y
cat file1 | sort | uniq -c | awk '{print $2"\t""COUNT"$1}'
adam,1,y        COUNT1
tony,1,x        COUNT2
tony,2,x        COUNT2
tony,3,x        COUNT1
tony,4,x        COUNT1
tony,5,x        COUNT1

Then second step

cat file1 | sort | uniq -c | awk '{print $2"\t""COUNT"$1}' | awk '{print $2}' | sort | uniq
COUNT1
COUNT2

Next step so search COUNT2 parameters

cat file1 | sort | uniq -c | awk '{print $2"\t""COUNT"$1}' | grep "COUNT2"
tony,1,x        COUNT2
tony,2,x        COUNT2

Unix is life. Always try to find easy way.

Regards,
Goksel Yangin
Computer Engineer

You posted nearly the same question here:

Please do not open up another thread just because of such an unsignificant difference. Else you get infractions for double posts. Keep that in mind, thanks.