Brian Dunning's FileMaker Custom Functions

SortArray ( valueList ; sortDirection ; dataType )

Sort an array (text, number, date or time ) ascending or descending

  Average rating: 3.7 (53 votes) Log in to vote

Mogens Brun   Mogens Brun - Show more from this author
FM Integrator
http://filemakerintegrator.dk

Share on Facebook Share on Twitter

  Sample input:
lorem
ipsum
dolor
sit
amet
consectetuer
adipiscing
elit
  Sample output:
adipiscing
amet
consectetuer
dolor
elit
ipsum
lorem
sit

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

Sort an array of either text, number, date or time values ascending or descending using the sort merge method (originally implemented for custom functions by Shaun Flisakowski and later by Theo Ros). The method is descriped in Wikipedia under "Merge sort".

Performance on a 1,66 GHz Mac Intel Core Duo: 50 word array: 60 msec. 100 word array: 150 msec. 500 word array : 1,1 sec. Sorting of dates are 30% faster.

20-25 times faster sorting of text arrays may be obtained using Troi Text Plug-in.

 

Comments

Richard DeShong   Richard DeShong, Logic Tools
Jun 7, 2023
Thank you, Mogens, for this merge-sort version. I was using a recursive bubble-sort, which worked great for short list (almost all of my uses were under 100 values). But I tried that version on a larger list (about 4000), and it would return just a question mark. My guess was that there were too many recursions.
But with this merge-sort version, it worked fine, even for about 4000 values.
 

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: