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
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.

Under construction. Email me your wish list for improvements.