JSON.ArraySort ( array ; nestedPath ; fmDataType ; direction ; sortLocale )
Sort a json array.
Be the first to rate this function Log in to vote
Josh Willing - Show more from this author
Willing Apps |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Sort an array by the value at `nestedPath` (leave empty if the array does not contain objects/arrays). Specify `fmDataType` to interpret the value at `nestedPath` as a specific filemaker data type, e.g. text/date/time/timestamp/number. Specify asc/desc for direction. And specify the sortLocale if needed to sort text for different locales.
This functions should gracefully handle both comma and periods as decimal separators. Please see the CF header for other caveats.
Examples:
Input: JSON.ArraySort("[5, 3, 8, 1, 2]"; ""; "number"; "asc"; "")
Output: [1,2,3,4,5]
Input: JSON.ArraySort("[{\"user\": {\"age\": 35}}, {\"user\": {\"age\": 21}}, {\"user\": {\"age\": 42}}]"; "user.age"; "number"; "asc"; "")
Output: [{"user":{"age":21}},{"user":{"age":35}},{"user":{"age":42}}]
Comments
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.