<doc>
	<legacy_id>1105</legacy_id>
	<name>sort container</name>
	<type>command</type>

	<syntax>
		<example>sort [{lines | items} of] container [direction] [sortType] [by sortKey ]</example>
	</syntax>

	<synonyms>
	</synonyms>

	<summary>Sorts the lines or items of a container into a new order.</summary>

	<examples>
<example><p>sort field "Output"</p></example>
<example><p>put "5,4,3,2,1" into tNumbers</p><p>sort items of tNumbers ascending numeric -- 5,4,3,2,1 becomes 1,2,3,4,5</p></example>
<example><p>put "1,ben" into line 1 of tData</p><p>put "2,elanor" into line 2 of tData</p><p>put "3,ali" into line 3 of tData</p><p>sort lines of tData descending numeric by item 1 of each </p><p></p><p># RESULT</p><p># 3,ali</p><p># 2,elanor</p><p># 1,ben</p></example>
<example><p>sort items of myInfo by word 2 of each -- sort by word 2 of the line</p></example>
<example><p></p></example>
	</examples>

	<history>
		<introduced version="1.0">Added.</introduced>
		<deprecated version=""></deprecated>
		<removed version=""></removed>
		
		<experimental version=""></experimental>
		<nonexperimental version=""></nonexperimental>
	</history>

	<objects>
	</objects>

	<platforms>
		<mac/>
		<windows/>
		<linux/>
		<ios/>
		<android/>
	</platforms>

	<classes>
		<desktop/>
		<server/>
		<web/>
		<mobile/>
	</classes>

	<security>
	</security>


	<classification>
		<category>Text and Data Processing</category>
		<category></category>
	</classification>

	<references>
		<function tag="offset">offset function</function>
		<command tag="convert">convert command</command>
		<command tag="sort">sort command</command>
		<keyword tag="ascending">ascending keyword</keyword>
		<keyword tag="descending">descending keyword</keyword>
		<keyword tag="text">text keyword</keyword>
		<keyword tag="each">each keyword</keyword>
	</references>

	<description>
	<overview>Use the sort container command to shuffle the order of lines or items in a container.</overview>

		<parameters>
  <parameter>
    <name>container</name>
    <description>Is a reference to a field, button, variable, or the message box.</description>
  </parameter>
  <parameter>
    <name>direction</name>
    <description>Is one of the following options. If you don't specify a direction, the sort is 'ascending'.</description>
    <options title="">
      <option>
        <item>ascending</item>
        <description>sorts in ascending order</description>
      </option>
      <option>
        <item>descending</item>
        <description>sorts in descending order</description>
      </option>
    </options>
  </parameter>
  <parameter>
    <name>sortType</name>
    <description>Is one of the following options. If you don't specify a sortType, the sortType is 'text'.</description>
    <options title="">
      <option>
        <item>text</item>
        <description>sorts using a codepoint by codepoint comparison</description>
      </option>
      <option>
        <item>binary</item>
        <description>sorts using a byte by byte comparison</description>
      </option>
      <option>
        <item>international</item>
        <description>sorts by collation according to the system locale</description>
      </option>
      <option>
        <item>numeric</item>
        <description>sorts by number. (Use this form if the sortKey consists of numbers)</description>
      </option>
      <option>
        <item>datetime</item>
        <description>treats the sortKey as a date and/or time</description>
      </option>
    </options>
  </parameter>
  <parameter>
    <name>sortKey</name>
    <description>is an expression that evaluates to a value for each line or item in the container. If the sortKey contains a chunk expression, the keyword each indicates that the chunk expression is evaluated for each line or item. If you don't specify a sortKey, the entire line (or item) is used as the sortKey.</description>
  </parameter>		</parameters>

	<value></value>
	<comments><p>If you don't specify lines or items, the lines of the container are sorted.</p><p></p><p>The each keyword, when used in the sortKey, specifies the entire line or item. You can use the each keyword in an expression, as a placeholder for the current line or item. For example, this statement sorts the lines of a variable by the third word of each line:</p><p></p><p>sort lines of myVariable by word 3 of each</p><p></p><p>You can use the each keyword in any expression, not just chunk expressions.</p><p></p><p>The sort container command is a stable sort. This means that if the sortKey for two items or lines is the same, sorting does not change their order, so you can do two successive sorts to create subcategories within the major sort categories.</p><p></p><p>Tip: To create a custom sort order, use the each keyword to pass each line or item to a custom function. The value returned by the function is used as the sort key for that line or item. It is not currently possible to debug custom sort functions, and doing so could make the IDE unstable. It is recommended to use logging messages instead.</p></comments>
	</description>
</doc>