Brian Dunning's FileMaker Custom Functions

SortList ( theList )

Sorts a return delimited list

  Average rating: 4.3 (3 votes) Log in to vote

Steve Thoms   Steve Thoms - Show more from this author
International Plastics
http://interplas.com

Share on Facebook Share on Twitter

  Sample input:
SortList ( "1¶7¶3¶9" )
  Sample output:
1
3
7
9

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

NOT FOR RUNTIMES - This wraps the list in JSON object notation with the list values as the keys. The values in the JSON are all 1. It returns JSONListKeys result. This function sorts the keys by default. If you want to sort dates, convert them to SQL or other text sortable format. Hope you like it. Thank you to Stam Kapetanakis for mentioning runtime incompatibility. UniqueValues() was added 24 Jul 2020 to avoid a parsing error; thanks to Brian Panhuyzen for noting the shortcoming.

 

Comments

Oliver Reid   Oliver Reid
Sep 21, 2019
Elegant and fast
 
Stam Kapetanakis   Stam Kapetanakis
Feb 15, 2020
Nice solution; only caveat is that it won't work with Runtime solutions (JSONListKeys not supported on Runtime).
 
Brian Panhuyzen   Brian Panhuyzen, Neutrino Data Systems
Jul 24, 2020
This code is elegant, however, when it hits a duplicate in the list it will generate something like:

? * Line 1, Column 389
Duplicate key: 'Alpine White'

...and if the function sorts based on an auto-enter calc, the error destroys your list.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: