Syntax10.Scn.Fnt4ParcElemsAllocr4Syntax10i.Scn.Fnt7+N 4'LineElemsAlloc #C "! Q&^4'Syntax8.Scn.Fnt\ ΗL\ Η:[LineSorter.Sort * LineSorter.ListDuplicates * LineSorter.Sort @ LineSorter.ListDuplicates @ LineSorter.List * ^ With LineSorter text lines terminated by CR can be sorted. For output a new text is generated. Text lines are considered as records of data with tabs as field separators. The sorting criteria (i.e. field numbers) can be given as parameter. White space other than tab and CR is considered to be part of the data. The output format of the lists may be different from input and can be specified as an additional parameter. LineSorter provides three commands: LineSorter.Sort: Sort a list and generate output in the specified form LineSorter.ListDuplicates: list all entries occuring more than once LineSorter.List: generate output in the specified form without sorting Parameter_Syntax for LineSorter.Sort and LineSorter.ListDuplicates: (For LineSorter.List the fieldlist-part has to be omited.) parameters := source { field } [ ^ | output_format ]. source := "*" | "@" | filename. field := [ "#" ] int. output_format := "[" { item } "]". item := """ text """ | "'" text "'" | "F" int | "T" | "C" | "B" | option. option := disjunct { disjunct } output_format. disjunct := "!" int | "~" int. As source may be used: the entire text of the marked viewer ("*") or the most recent selection ("@") or a text_file specified by its name. As sorting criteria a list of field numbers may be given. The first field is the primary sorting criteria. A preceding "#" indicates, that the field is to be interpreted as a positive integer value. If no field number is specified, the entire line will be used for comparison. The output format consists of a sequence of fixed text given in quotes field numbers preceded by an "F" commands to insert tabs ("T"), carriage returns ("C") or blanks ("B") options, consisting of a test and a output description that is used, if the test holds The fixed text will be replicated preserving all the text attributes and text elements. The text attributes for field output will be the same as of the preceding "F"_character in the specification. The text attributes of the white space characters specified by "T", "C" or "B" will be identical with these of the specifying character. Options might be used for conditional output. the output format specified in an option is printed only, if at least one of the disjuncts listed holds. Each disjunct is a statement whether a specific field is expected to be empty or non empty. To require non_emptiness the exclamation mark ("!") is used, to require emptiness, the tilde ("~") is written. These symbols need to be followed immediately by the number of a field. Omission of the output specification will result in output of the lines in the original form, preserving text attributes and text elements. If the up_arrow is used, the most recent selection will be used for output specification. Copyright: ww 2 Nov 94 Weck@inf.ethz.ch  Some Examples: Sort lines of text in marked viewer: LineSorter.Sort * List repeated lines: LineSorter.ListDuplicates * Sample commands for use with address list (see sample text below) Sort according to Town: LineSorter.Sort @ 6 Find double towns: LineSorter.ListDuplicates @ 6 Sort according to several criteria: LineSorter.Sort @ 2 1 3 6 Sort according to number of calls: LineSorter.Sort @ #9 Phonelist: LineSorter.List @ [ !8[ F2 !2[", "] F1 !1[", "] F3 ~3[F6] T F7 !7[" "] F8 C ]] Alphabetical phonelist of institutions: LineSorter.Sort @ 3 2 1 [ !8[ !3[ F3 !1!2[" (" F1 !1[!2[B]] F2 ")"] T F7 !7[" "] F8 C ] ] ] Prettyprinted list: LineSorter.List @ [ F1 !1[!2[B]] F2 !3[!1!2[", "]] F3 C F4 !4[!5!6[", "]] F5 !5[B] F6 !4!5!6[C] !8[!7["(" F7 ") "] F8 C ] C ] sample text: address list (Select the text below and execute commands above)   Firstname Name Institution Address ZIP Town Area Code Phone number of calls  John Main-Street 101 Charly ++1 558 747 4747 1 Garbage Inc. 0815 4711 7 Fire & Ice Corp. 42 Cool-Street CA 94103 San Francisco 001 415 365 5555 16 Paul Mustermann Wohnstrasse 7a CH-8006 Zrich 123 45 67 33 Wolfgang Weck Inst. fr Wissensch. Rechnen ETH-Zentrum CH-8092 Zrich ++41 1 63 274 76 0