{"identifier":48321,"topic":"Commands","name":"sort","text":"<code>sort <\/code>[<i><code>sortDirection<\/i><\/code> ]<code> <\/code>[<i><code>sortStyle<\/i><\/code> ]<code> <\/code>\u00ac <code><pre>     by <i>expression<\/i>\n<\/pre><\/code>\n<code>sort <\/code>[<code>this<\/code>]<code> stack <\/code>[<i><code>sortDirection<\/i><\/code> ]<code> <\/code>\u00ac           [<i><code>sortStyle<\/i><\/code> ]<code> by <i>expression<\/i> sort <\/code>[<code>marked<\/code>]<code> cards <\/code>[<code>of this stack<\/code>]<code> <\/code>\u00ac<code>      <\/code>[<i><code>sortDirection<\/i><\/code> ]<code> <\/code>[<i><code>sortStyle<\/i><\/code> ] \u00ac         <code> by <i>expression<\/i> <br><br>\n\n sort <i>bkgnd<\/i> <\/code>[<i><code>sortDirection<\/i><\/code> ]<code> <\/code>\u00ac           [<i><code>sortStyle<\/i><\/code> ]<code> by <i>expression<\/i> sort <\/code>[<code>marked<\/code>]<code> cards of <i>bkgnd<\/i> <\/code>\u00ac<code>      <\/code>[<i><code>sortDirection<\/i><\/code> ]<code> <\/code>[<i><code>sortStyle<\/i><\/code> ] \u00ac         <code> by <i>expression<\/i><\/code> <br>\n<br>\n<code>sort <\/code>[<i><code>chunks<\/i> of<\/code>]<code> <i>container<\/i> <\/code>\u00ac           [<i><code>sortDirection<\/i><\/code> ]<code> <\/code>[<i><code>sortStyle<\/i><\/code> ]<code> <\/code>\u00ac           [<code>by <i>expression<\/i><\/code> ] <br><br>\n\n where<code> <i>chunks<\/i> <\/code>are limited to either<code> <\/code>lines or items<code>.<\/code> (See next card for details.) <br><br>\n\n The first five forms of the<code> sort <\/code>command order all the cards in a stack or background by the value of<code> <i>expression<\/i>,<\/code> evaluated  for each card in the stack or background. <br>\n","related":{"41060":"mark"},"examples":"-- Sort a container:\n\nsort lines of card field 1\nsort items of card field 1\nsort lines of myVariable descending numeric\nsort items of Message box\nsort lines of the selection\nsort lines of field 1 by last word of each -- by last word of each line\nsort items of fld 1 descending numeric by word 2 of each\nsort items of myList by the random of 2000 -- reorder myList randomly\nsort lines of fld 1 numeric by length(cd fld each) -- if field 1\n            -- contains names of cd flds, orders names according \n            -- to number of characters in each field.\n\n-- Sort cards:\n\nsort by bkgnd field \"Name\"\nsort this stack by bkgnd field \"Name\"\nsort stack by bkgnd field \"Name\"\nsort marked cards of this stack by bkgnd field \"Name\"\n\nsort this background by bkgnd field \"Name\"\nsort background 2 by bkgnd field \"Name\"\nsort marked cards of previous background by bkgnd field \"Name\"\n\nsort descending by bkgnd field \"Name\"\nsort descending international by bkgnd field \"Name\"\n\nsort numeric by bkgnd field 2\nsort numeric by the id of this card\n\nsort by (bkgnd field \"Last Name\" & bkgnd field \"First Name\")\nsort by mySortFunction()","demo":"on sortMe\n   put line 10 to 13 of me into theLines\n   select line 10 to 13 of me\n   wait 30\n   sort lines of the selection\n   wait 1 second\n   put theLines into line 10 to 13 of me\n end sortMe\n <br><br>\n\n Zeppo\n Chico\n Groucho\n Harpo<b>\n <\/b>\n ","debug":{"9":["sort [sortDirection "],"10":["sort [chunks of] con"]}}