Returns all lines from theText sorted in alphabetical order. The direction of the sort is determined by the switches.
TrText_SortLines( switches ; theText )
|determine the sort direction
|the text to be sorted
Switches can be one of:
|(default) sort in ascending order (A…Z)
|sort in descending order (Z…A)
You can also add one of these switches:
|sort with the raw unicode bytes (like the old ASCII ordering)
|sort using FileMaker’s way (SLOW)
|(default) sort using Troi’s sorting
You can also add this extra switch:
|add a return at the end
Data type returned
All the lines from TextField sorted in alphabetical order.
Troi Text Plug-in 1.2
FileMaker Pro 16 to 19
If switches is empty the sort order is ascending.
The calculation in which this function is used can be both stored and unstored. You can use this function in calculation field definitions or in script calculations.
TrText_SortLines( "-Descending" ; Text )
Say text field “Text” consists of date strings (YYYY-MMDD), for example the following lines:
The result of SortLines will be:
In this case the latest date will be sorted first.
We assume that in your FileMaker file the following fields are defined:
gDirection Global, text
Create the following calculation:
Set Field [ result ; TrText_SortLines ( gDirection ; Text ) ]
Put the field gDirection on the layout and create a valuelist with “-Descending”. Format the field as a checkbox for it. Then by checking and unchecking gDirection you can instantly change the sort direction.