sort

Typecommand
DictionaryLCS
LibraryLiveCode Script
Syntax
sort [marked] cards [of <stack>] [<direction>] [<sortType>] by <sortKey>
Summary

Sorts the cards of a stack into a new order.

Introduced1.0
OSmac, windows, linux, ios, android
Platformsdesktop, server, mobile
Parameters
NameTypeDescription
stack

A reference to any open stack. If you don't specify a stack, the cards of the current stack are sorted.

direction

If you don't specify a direction, the sort is ascending.

ascending: sorts in ascending order
descending: sorts in descending order
sortType

If you don't specify a sortType, the sortType is text.

international: sorts by collation according to the system locale
numeric: sorts by number. (Use this form if the sortKey consists of numbers)
datetime: treats the sortKey as a date and/or time
text: sorts using a codepoint by codepoint comparison
binary: sorts using a byte by byte comparison
sortKey

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.

Example
sort cards by field "name"
sort cards of this stack by random(the number of cards)
sort marked cards of stack "project1" numeric by the number of buttons
sort cards numeric by the short ID of this card
sort cards of stack "Manson" descending dateTime by item 1 of field "Date"
RelatedCommand: find, sort container, filter
Keyword: dateTime, numeric, text
Property: mark
Description

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.

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:

sort cards by field "Last Name"
sort cards numeric by field "ZIP code"

The 'text' and 'international' forms are affected by the caseSensitive and formSensitive properties.

Tagsdatabase