Duplicate sort

Pipelines v1.6

 

.* Example by TenFiftyTwo(c).

Home

 
.* The following pipeline reads the file: example.txt, splits each record at a word boundary,
.* translates the records to lowercase, sorts the records to identify duplicates, arranges the
.* resulting records in descending order of occurrence, and finally builds a four column
.* aligned output matrix.
 
pipe (endchar ?)
     < &installdrive:\&installpath\Examples\Input\example.txt .* Read input file.
     | xlate x01-x2f x20                .* Remove all but 0-9, a-z, A-Z and '(quote)
             x3a-x40 x20
             x5b-x5f x20
             x7b-xff x20
             ' '
     | split                            .* Split record at word boundary.
     | strip                            .* Strip whitespace.
     | a: locate                        .* Route away null records.
     | b: faninany                      .* Merge streams.
     | xlate lower                      .* Translate to lowercase.
     | sort count                       .* Sort with duplicate count.
     | sort 1-10 d                      .* Arrange them in descending order of occurrence.
     | snake 4 align                    .* Build a 4 column aligned output matrix.
     | cons                             .* Display on the console.
     ?
     a:
     | specs '(blank line)' 1           .* Give a null record a description.
     | b: