TrText_SortLines (function reference)

By November 1, 2017 November 13th, 2017 Online Help, Troi Text Plug-in
Troi Text Plug-in for FileMaker Pro

TrText_SortLines

Returns all lines from theText sorted in alphabetical order. The direction of the sort is determined by the switches.

SyntaxFunction badge

TrText_SortLines( switches ; theText )

Parameters

switchesdetermine the sort direction
theTextthe text to be sorted

Switches

Switches can be one of:

-Ascending(default) sort in ascending order (A…Z)
-Descendingsort in descending order (Z…A)

You can also add one of these switches:

-SortUnicodeRawsort with the raw unicode bytes (like the old ASCII ordering)
-SortUnicodeFMPsort using FileMaker’s way (SLOW)
-SortUnicodeTroi(default) sort using Troi’s sorting

You can also add this extra switch:

-ReturnAtEndadd a return at the end

Returned Result

Data type returned

Text

Result

All the lines from TextField sorted in alphabetical order.

Originated in

Troi Text Plug-in 1.2

Compatibility

FileMaker Pro 12 to 16

Considerations

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.

Example

TrText_SortLines( "-Descending" ; Text )

Say text field “Text” consists of date strings (YYYY-MMDD), for example the following lines:
2000-1221
1999-0529
2000-1226

The result of SortLines will be:
2000-1226
2000-1221
1999-0529

In this case the latest date will be sorted first.

Example 2

We assume that in your FileMaker file the following fields are defined:

Text		Text
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.

Related functionFunction badge

TrText_UniqueWords

Related topics

Troi Text Plug-in online help (overview)


Online Help Page for Troi Text Plug-in for 12 to 16 –> TrText_SortLines (textp9) 2017-1112 16:51:28