QuickList.SortWith
------------------

Sorts the list with together with other lists.

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

MBS( "QuickList.SortWith"; ListRef; Flags; List1 { ; List2... } ) 

**MBS**( **"QuickList.SortWith";** /\* Sorts the list with together with other lists. \*/  
**$ListRef**; /\* The reference to the list returned from [QuickList.New](QuickListNew.md) function.e.g. $List \*/   
**$Flags**; /\* Optional, whether to sort case insensitive or descending.   
Pass 1 to sort case insensitive or 0 to sort case sensitive.   
Add 2 to sort descending.  
Add 4 for sorting dates in DD.MM.YYYY style and 8 for sorting dates in MM.DD.YYYY style.  
Add 16 to sort by numbers.e.g. 1 \*/   
**$List1**; /\* The first list to sort with. \*/   
**$List2...**) /\* Optional; The second list to sort with.e.g. $list2 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| ListRef | The reference to the list returned from [QuickList.New](QuickListNew.md) function. | $List |  |
| Flags | Optional, whether to sort case insensitive or descending.    Pass 1 to sort case insensitive or 0 to sort case sensitive.    Add 2 to sort descending.   Add 4 for sorting dates in DD.MM.YYYY style and 8 for sorting dates in MM.DD.YYYY style.   Add 16 to sort by numbers. | 1 |  |
| List1 | The first list to sort with. | $list1 |  |
| List2... | The second list to sort with. | $list2 | Optional |

### Result

Returns OK or error.

### Description

Sorts the list with together with other lists.  
We sort the first list and move all items in other lists as well to match the order.  
You can pass as many lists in the parameters as needed, not just 2.  
  
Add mode 16 for flags to sort by numbers for version 11.0.  
  
This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.  
Please repeat List2 parameter as often as you need.  
### Examples

Test sorting with four lists:

 # build some lists   
Set Variable \[$keys ; Value:MBS ( "[QuickList.New](QuickListNew.md)"; "234¶123¶545¶152" )\]  
Set Variable \[$firstnames ; Value:MBS ( "[QuickList.New](QuickListNew.md)"; "Bob¶John¶Bill¶Chris" )\]  
Set Variable \[$lastnames ; Value:MBS ( "[QuickList.New](QuickListNew.md)"; "Miller¶Jones¶Becks¶Meyer" )\]  
Set Variable \[$cities ; Value:MBS ( "[QuickList.New](QuickListNew.md)"; "New York¶Santa Clara¶San Francisco¶Atlanta" )\]  
\# show before   
Set Variable \[$r1 ; Value:MBS ( "[List.CrossProduct](ListCrossProduct.md)"; MBS ("[QuickList.GetList](QuickListGetList.md)"; $keys ); MBS ("[QuickList.GetList](QuickListGetList.md)"; $firstnames ); ""; ": "; ""; 2)\]  
Set Variable \[$r2 ; Value:MBS ( "[List.CrossProduct](ListCrossProduct.md)"; MBS ("[QuickList.GetList](QuickListGetList.md)"; $lastnames ); MBS ("[QuickList.GetList](QuickListGetList.md)"; $cities ); ""; ", "; ""; 2)\]  
Set Variable \[$r3 ; Value:MBS ( "[List.CrossProduct](ListCrossProduct.md)"; $r1 ; $r2 ; ""; ", "; ""; 2)\]  
\# sort   
Set Variable \[$r ; Value:MBS ( "QuickList.SortWith"; $keys ; 0; $firstnames ; $lastnames ; $cities )\]  
\# show result:   
Set Variable \[$r1 ; Value:MBS ( "[List.CrossProduct](ListCrossProduct.md)"; MBS ("[QuickList.GetList](QuickListGetList.md)"; $keys ); MBS ("[QuickList.GetList](QuickListGetList.md)"; $firstnames ); ""; ": "; ""; 2)\]  
Set Variable \[$r2 ; Value:MBS ( "[List.CrossProduct](ListCrossProduct.md)"; MBS ("[QuickList.GetList](QuickListGetList.md)"; $lastnames ); MBS ("[QuickList.GetList](QuickListGetList.md)"; $cities ); ""; ", "; ""; 2)\]  
Set Variable \[$r4 ; Value:MBS ( "[List.CrossProduct](ListCrossProduct.md)"; $r1 ; $r2 ; ""; ", "; ""; 2)\]  
Show Custom Dialog \["Sort results"; "Before: " &amp; ¶ &amp; $r3 &amp; ¶ &amp;¶ &amp; "Sorted: " &amp; ¶ &amp; $r4 \]  
\# cleanup memory   
Set Variable \[$r ; Value:MBS ( "[QuickList.Release](QuickListRelease.md)"; $keys )\]  
Set Variable \[$r ; Value:MBS ( "[QuickList.Release](QuickListRelease.md)"; $cities )\]  
Set Variable \[$r ; Value:MBS ( "[QuickList.Release](QuickListRelease.md)"; $firstnames )\]  
Set Variable \[$r ; Value:MBS ( "[QuickList.Release](QuickListRelease.md)"; $lastnames )\]  
Sort a list column:

 Set Variable \[ $List ; Value: "65412|Schreiber|Klaus|459oz8235" &amp; ¶ &amp; "76542|Abraham|Hermmann|38957zf" &amp; ¶ &amp; "85112|Behrens|Robert|489748hj" \]   
Set Variable \[ $QuickList1 ; Value: MBS ( "[QuickList.New](QuickListNew.md)"; $list ) \]   
\#   
Set Variable \[ $QuickList2 ; Value: MBS ( "[QuickList.DeCombine](QuickListDeCombine.md)"; $QuickList1 ; "|"; 1 /\* StartColumn\*/; 1 /\* EndColumn \*/; 1 /\* New List\*/ ) \]   
Set Variable \[ $List2 ; Value: MBS ( "[QuickList.GetList](QuickListGetList.md)"; $QuickList2 ) \]   
Set Variable \[ $r ; Value: MBS ( "QuickList.SortWith"; $QuickList2 ; 1; $QuickList1 ) \]   
Set Variable \[ $List1 ; Value: MBS ( "[QuickList.GetList](QuickListGetList.md)"; $QuickList1 ) \]   
\#   
Set Variable \[ $r ; Value: MBS ( "[QuickList.Release](QuickListRelease.md)"; $QuickList1 ) \]   
Set Variable \[ $r ; Value: MBS ( "[QuickList.Release](QuickListRelease.md)"; $QuickList2 ) \]  
### See also

- [List.CrossProduct](ListCrossProduct.md)
- [List.DeCombine](ListDeCombine.md)
- [List.Sort](ListSort.md)
- [QuickList.DeCombine](QuickListDeCombine.md)
- [QuickList.GetList](QuickListGetList.md)
- [QuickList.New](QuickListNew.md)
- [QuickList.Release](QuickListRelease.md)
- [QuickList.SetList](QuickListSetList.md)
- [QuickList.Sort](QuickListSort.md)

### Release notes

- **Version 11.0**
    - Added mode 16 for number sorting to [QuickList.SortWith](https://www.mbsplugins.eu/QuickListSortWith.shtml) function.
- **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

- [Neues MBS FileMaker Plugin 11.0](https://www.mbsplugins.de/archive/2021-01-19/Neues_MBS_FileMaker_Plugin_110/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.0 - More than 6400 Functions In One Plugin](https://www.mbsplugins.de/archive/2021-01-19/MBS_FileMaker_Plugin_110_-_Mor/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.6pr2](https://www.mbsplugins.de/archive/2020-12-08/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.2pr2](https://www.mbsplugins.de/archive/2016-03-29/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 25th March 2016 , last changed 14th December 2023

  
[QuickList.Sort](QuickListSort.md) - [QuickList.SortWithEvaluate](QuickListSortWithEvaluate.md)

[HTML Version](QuickListSortWith.shtml)