Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 9.0   9.1   9.2   9.3   9.4   9.5   10.0   10.1   10.2   10.3    Statistic  


Sorts the JSON array/object using an expression to evaluate.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
JSON 10.2 Yes Yes Yes Yes Yes
MBS( "JSON.SortWithEvaluate"; json; Expression )   More


Parameter Description Example value
json A JSON text or reference. [2,9,3,1]
Expression The expression to evaluate.
Can include "leftJSON", "rightJSON" as variables.
You can call other MBS JSON functions if needed.
"(leftJSON) > GetAsNumber(rightJSON)"


Returns OK or error.


Sorts the JSON array/object using an expression to evaluate.
The expression is run every time two values are compared, so keep it quick. It should return 1 if leftJSON is smaller than rightJSON.

Our normal JSON.Sort is faster due to not having the overhead of evaluating expressions.


Sort with evaluate:

MBS( "JSON.SortWithEvaluate"; "[2,9,3,1]"; "MBS( \"JSON.GetValue\"; leftJSON) < MBS( \"JSON.GetValue\"; rightJSON)" )

Sort a list of object by name:

MBS( "JSON.SortWithEvaluate"; "[
{\"name\": \"Joe\"},
{\"name\": \"Anna\"},
{\"name\": \"Tim\"},
{\"name\": \"John\"}
]"; "JSONGetElement ( leftJSON; \"name\") < JSONGetElement ( rightJSON; \"name\")" )

See also

Blog Entries

Release notes

  • Version 10.2

Created 9th April 2020, last changed 9th April 2020


Feedback: Report problem or ask question.

MBS Xojo Chart Plugins