<doc>
	<legacy_id>2104</legacy_id>
	<name>sort</name>
	<type>command</type>

	<syntax>
		<example>sort [marked] cards [of stack] [direction] [sortType] by sortKey</example>
		<example></example>
		<example></example>
		<example></example>
	</syntax>

	<synonyms>
	</synonyms>

	<summary>Sorts the cards of a stack into a new order.</summary>

	<examples>
<example><p>sort cards by field "name"</p></example>
<example><p>sort cards of this stack by random(the number of cards)</p></example>
<example><p>sort marked cards of stack "project1" numeric by the number of buttons</p></example>
<example><p>sort cards numeric by the short ID of this card</p></example>
<example><p>sort cards of stack "Manson" descending dateTime by item 1 of field "Date"</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>Database Operations</category>
		<category></category>
		<category></category>
		<category></category>
	</classification>

	<references>
		<command tag="sort container">sort container command</command>
		<command tag="find">find command</command>
		<command tag="filter">filter command</command>
		<property tag="mark">mark property</property>
		<keyword tag="text">text keyword</keyword>
		<keyword tag="dateTime">dateTime keyword</keyword>
		<keyword tag="numeric">numeric keyword</keyword>
	</references>

	<description>
	<overview>Use the sort command to shuffle the cards in a stack into a new order, or to shuffle a subset of the cards in a stack.</overview>

		<parameters>
  <parameter>
    <name>stack</name>
    <description>Is a reference to any open stack. If you don't specify a stack, the cards of the current stack are sorted.</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 card in the stack. Any object references within the sortKey are treated as pertaining to each card being evaluated, so for example, a reference to a field is evaluated according to that field's contents on each card.</description>
  </parameter>		</parameters>

	<value></value>
	<comments><p>The sort command is a stable sort. This means that if the sortKey for two cards is the same, sorting does not change their order, so you can do two successive sorts to create subcategories within the major sort categories. For example, to sort the cards of a stack by ZIP code and sort within each ZIP code by last names, use these two statements:</p><p></p><p>sort cards by field "Last Name"</p><p>sort cards numeric by field "ZIP code"</p><p></p><p>The 'text' and 'international' forms are affected by the caseSensitive and formSensitive properties.</p></comments>
	</description>
</doc>