in reply to Re: Sorting and counting 5 Million lines
in thread Dear Monks

It's a long "one-liner" (broken up for readability), but this I think meets the requirements:
sort <<EOT | tr ',' ' ' | uniq -c | awk '{ if ( tag != $2 ) { if ( tot > 0 ) { print tot, tag, countries } tot=$1; tag=$2; countries=$3; next; } tot += $1; countries = countries "," $3; } END { print tot, tag, countries }' abcd,US abee,UK abcd,US adee,US adee,UK EOT