[PLUG] Sorting blocks of text

Rich Shepard rshepard at appl-ecosys.com
Tue Nov 29 00:16:03 UTC 2016


On Tue, 22 Nov 2016, Scott Bigelow wrote:

> Not sure if I understand your input format well enough, but I think awk
> can handle it, something like:
>
> awk  'BEGIN {RS="\n\n"} { v[$0]++ } END { n = asorti(v,copy);
> for(i = 1; i <= n; i++){ print copy[i] } }'

Scott,

   I understand how this works and it does a good job, except for putting the
first block at the end with no spaces. Perhaps the code is missing the first
block?

   I've attached a data file if you'd like to play with it. In the meantime,
I manually move the last block to its proper alphabetically order.

   It's interesting that I find no examples of this function on the web or in
'Effective Awk Programming, 3rd Ed.'

Thanks,

Rich
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: call-list-cities.txt
URL: <http://lists.pdxlinux.org/pipermail/plug/attachments/20161128/5468b176/attachment.txt>


More information about the PLUG mailing list