Skip to main content

TrText_SortLines (function reference)

By October 1, 2024October 10th, 2024Online 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

switches determine the sort direction
theText the text to be sorted

Switches

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

Text

Result

All the lines from TextField sorted in alphabetical order.

Originated in

Troi Text Plug-in 1.2

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

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 17 to 2024 –> TrText_SortLines (textp9) 2024-1010 14:48:00