Brian Dunning's FileMaker Custom Functions

CustomQuickSort ( values ; valueFunction ; direction )

QuickSort using custom evaluation

  Average rating: 3.5 (2 votes) Log in to vote

Richard Dyce   Richard Dyce - Show more from this author
Dyce & Sons Ltd.
http://dyce.com

Share on Facebook Share on Twitter

  Sample input:
CustomQuickSort ( "3,5¶4,2¶1,3¶4,1¶1,7¶2,0¶1,9" ; "Middle( \"[t]\" ; Position( \"[t]\" ; \",\" ; -1 ; 1 ) + Length( \",\" ) ; 64000 )" ; True )
  Sample output:
"2,0¶4,1¶4,2¶1,3¶3,5¶1,7¶1,9"

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

This is an extension of the existing QuickSort( list ) function from Jeremy Bante ( OshVay Systems, Inc. http://www.oshvay.com).

It allows you to effectively use a comparison function so that you can sort more complex values. For example, given a list of coordinates:

"3,5¶4,2¶1,3¶4,1¶1,7¶2,0¶1,9"

You can sort them by their y coordinate:

CustomQuickSort ( "3,5¶4,2¶1,3¶4,1¶1,7¶2,0¶1,9" ; "GetAsNumber( Middle( \"[t]\" ; Position( \"[t]\" ; \",\" ; -1 ; 1 ) + Length( \",\" ) ; 64000 ) )" ; True )

gives:

"2,0¶4,1¶4,2¶1,3¶3,5¶1,7¶1,9"

 

Comments

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: