!($2 in seen) { seen[$2] = 1; order[++n] = $2 } { count[$2]++ } END { for (i = 1; i <= n; i++) print order[i], count[order[i]] }