Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 9.3   9.4   9.5   10.0   10.1   10.2   10.3   10.4   10.5   11.0    Statistic    FMM    Blog  

QuickList.SortWith

Sorts the list with together with other lists.

Component Version macOS Windows Linux Server FileMaker iOS SDK
List 6.2 Yes Yes Yes Yes Yes
MBS( "QuickList.SortWith"; ListRef; Flags; List1 { ; List2 } )   More

Parameters

Parameter Description Example Flags
ListRef The reference to the list returned from QuickList.New 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.

Examples

Test sorting with four lists:

# build some lists
Set Variable [$keys; Value:MBS( "QuickList.New"; "234¶123¶545¶152" )]
Set Variable [$firstnames; Value:MBS( "QuickList.New"; "Bob¶John¶Bill¶Chris" )]
Set Variable [$lastnames; Value:MBS( "QuickList.New"; "Miller¶Jones¶Becks¶Meyer" )]
Set Variable [$cities; Value:MBS( "QuickList.New"; "New York¶Santa Clara¶San Francisco¶Atlanta" )]
# show before
Set Variable [$r1; Value:MBS( "List.CrossProduct"; MBS("QuickList.GetList"; $keys); MBS("QuickList.GetList"; $firstnames); ""; ": "; ""; 2)]
Set Variable [$r2; Value:MBS( "List.CrossProduct"; MBS("QuickList.GetList"; $lastnames); MBS("QuickList.GetList"; $cities); ""; ", "; ""; 2)]
Set Variable [$r3; Value:MBS( "List.CrossProduct"; $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"; MBS("QuickList.GetList"; $keys); MBS("QuickList.GetList"; $firstnames); ""; ": "; ""; 2)]
Set Variable [$r2; Value:MBS( "List.CrossProduct"; MBS("QuickList.GetList"; $lastnames); MBS("QuickList.GetList"; $cities); ""; ", "; ""; 2)]
Set Variable [$r4; Value:MBS( "List.CrossProduct"; $r1; $r2; ""; ", "; ""; 2)]
Show Custom Dialog ["Sort results"; "Before: " & ¶ & $r3 & ¶ &¶ & "Sorted: " & ¶ & $r4]
# cleanup memory
Set Variable [$r; Value:MBS( "QuickList.Free"; $keys)]
Set Variable [$r; Value:MBS( "QuickList.Free"; $cities)]
Set Variable [$r; Value:MBS( "QuickList.Free"; $firstnames)]
Set Variable [$r; Value:MBS( "QuickList.Free"; $lastnames)]

Sort a list column:

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

See also

Blog Entries

Release notes

Created 25th March 2016, last changed 28th November 2020


QuickList.Sort   -   QuickList.SortWithEvaluate

Feedback: Report problem or ask question.




Links
MBS Xojo PDF Plugins

Start Chat