Sort

This phase performs a simple alphabetic sort to appease PROLOG.

PROLOG requires that facts be grouped together. Alphabetic sorting is not required, but is easy to perform and creates an acceptable grouping.

[In fact, modern PROLOG engines allow un-grouped facts. This requires a bit of extra syntax. It would have been possible to leave the factbase un-grouped, but, the object of this set of essays is to show that it is easy to compose pipelines of grok/emit phases, so we chose to insert this simple sorting phase.]

This phase simply accepts the input (the result of the preceding phase) and calls JS sort() to produce the final output string.

2021-07-30 sort.png

[This is probably something a Production Engineer would attack early, but, in Software Architecture, we strive for obvious-ness instead of machine-level efficiency. Again, the use of a grok/emit pipeline makes it easy to construct architectures without worrying about fine-grained details.]

See Also

Blog
References