List.SortWithEvaluate
---------------------

Sorts a list with using an expression to evaluate.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [List](component_List.md) | [10.2](newinversion102.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "List.SortWithEvaluate"; List; Expression { ; NoReturnEnding } ) 

**MBS**( **"List.SortWithEvaluate";** /\* Sorts a list with using an expression to evaluate. \*/  
**$List**; /\* The list to sort.e.g. "Hello" ¶ "World" \*/   
**$Expression**; /\* The expression to evaluate.  
Can include "leftValue" and "rightValue" as variables.e.g. "leftValue &gt; rightValue" \*/   
**$NoReturnEnding**) /\* Optional; Pass 1 to have no extra newline character on the end of the returned list. Default is 0 to include one to easily concat lists.e.g. 1 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| List | The list to sort. | "Hello" ¶ "World" |  |
| Expression | The expression to evaluate.   Can include "leftValue" and "rightValue" as variables. | "leftValue &gt; rightValue" |  |
| NoReturnEnding | Pass 1 to have no extra newline character on the end of the returned list. Default is 0 to include one to easily concat lists. | 1 | Optional |

### Result

Returns OK or error.

### Description

Sorts a list with using an expression to evaluate.  
The expression is run every time two values are compared, so keep it quick. It should return 1 if leftValue is smaller than rightValue.  
  
Our normal [List.Sort](ListSort.md) is faster due to not having the overhead of evaluating expressions.  
### Examples

Sort numbers numeric with GetAsNumber() function:

 MBS ("List.SortWithEvaluate"; "1¶22¶3"; "GetAsNumber(leftValue) &lt; GetAsNumber(rightValue)")  
<small>  
Example result:   
1  
3  
22</small>Sort dates with using GetAsDate:

 MBS ("List.SortWithEvaluate"; "1/1/2000¶2/22/2020¶3/4/1998"; "GetAsDate(leftValue) &lt; GetAsDate(rightValue)")  
### See also

- [JSON.SortWithEvaluate](JSONSortWithEvaluate.md)
- [List.Sort](ListSort.md)
- [QuickList.SortWithEvaluate](QuickListSortWithEvaluate.md)

### Release notes

- **Version 10.2**
    - Added [List.SortWithEvaluate](https://www.mbsplugins.eu/ListSortWithEvaluate.shtml) and [QuickList.SortWithEvaluate](https://www.mbsplugins.eu/QuickListSortWithEvaluate.shtml) functions to sort lists with custom expression.

### Blog Entries

- [News about the MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-19/News_about_the_MBS_FileMaker_P/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-12/Neues_MBS_FileMaker_Plugin_102/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 10.2 - More than 6200 Functions In One Plugin](https://www.mbsplugins.de/archive/2020-05-12/MBS_FileMaker_Plugin_102_-_Mor/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.2pr3](https://www.mbsplugins.de/archive/2020-04-14/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Sort with evaluate in FileMaker](https://www.mbsplugins.de/archive/2020-04-10/Sort_with_evaluate_in_FileMake/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

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

  
[List.Sort](ListSort.md) - [List.SubList](ListSubList.md)

[HTML Version](ListSortWithEvaluate.shtml)