Skip to main content

TrText_SortLines (function reference)

By December 1, 2021December 21st, 2021Online Help, Troi Text Plug-in
Troi Text Plug-in for FileMaker Pro


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 )


switches determine the sort direction
theText the text to be sorted


Switches can be one of:

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

You can also add one of these switches:

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

You can also add this extra switch:

-ReturnAtEnd add a return at the end

Returned Result

Data type returned



All the lines from TextField sorted in alphabetical order.

Originated in

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.

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


Related topics

Troi Text Plug-in online help (overview)

Online Help Page for Troi Text Plug-in for 16 to 19 –> TrText_SortLines (textp9) 2021-1221 15:11:24