|
sort
|
Overview
The sort function returns a sorted copy of the specified
Structure, Dictionary, Directory, Vector, Matrix, Pair or List argument
{target} in the order specified by the argument predicate {predicate}.
If the optional Boolean argument {true} is present, the sort function does not
sort the specified target; but instead, returns a sorted integer vector of indices
into the specified target.
Usage
The sort function sorts all the elements in a vector and returns the sorted
version of the Vector. The sort function is destructive except for the option
containing the keyword {true}, which returns a new sorted integer vector.
Structure
The sort function can be used to sort an AIS Object by the values or by keys,
destructively or non-destructively.
Dictionary
The sort function can be used to sort an AIS Object by the values or by keys,
destructively or non-destructively.
Directory
The sort function can be used to sort an AIS Object by the values or by keys,
destructively or non-destructively.
List
The sort function can be used to sort an AIS Object by the values or by keys,
destructively or non-destructively.
Matrix
The sort function sorts all the elements in a Matrix and returns the sorted
version of the Matrix . The sort function is destructive except for the option
containing the keyword {true}, which returns a new sorted integer Matrix .
NumMatrix
The sort function sorts all the elements in a NumMatrix and returns the sorted
version of the NumMatrix . The sort function is destructive except for the option
containing the keyword {true}, which returns a new sorted integer NumMatrix .
Syntax
Expression: |
(sort vector predicate )
(sort vector predicate true))
|
Arguments |
Name |
Type |
Description |
Argument: | vector | Vector FltVector ShortVector IntVector NumVector ObjVector BitVector |
The vector to be sorted |
---|
Argument: | predicate | Word |
predicate > means sort in descending order, predicate < means sort in
ascending order |
---|
Argument: | true | Boolean |
Optional argument: If present it means to return an integer vector
containing sorted indices to the vector. |
---|
Returns: |
The sorted Vector.
|
---|
Expression: |
(sort struct predicate )
(sort struct predicate true))
|
Arguments |
Name |
Type |
Description |
Argument: | struct | Structure |
The structure to be sorted |
---|
Argument: | predicate | Word |
predicate > means sort in descending order, predicate < means sort in
ascending order |
---|
Argument: | true | Boolean |
Optional argument: If present it means to return an integer vector
containing sorted indices to the structure. |
---|
Returns: |
If {true} is present, an integer vector containing the sorted indices to
the structure is returned. If {true} is not present, the sorted structure is returned.
|
---|
Expression: |
(sort dict predicate )
(sort dict predicate true))
|
Arguments |
Name |
Type |
Description |
Argument: | dict | Dictionary |
The dictionary to be sorted |
---|
Argument: | predicate | Word |
predicate > means sort in descending order, predicate < means sort in
ascending order |
---|
Argument: | true | Boolean |
Optional argument: If present it means to return an integer vector
containing sorted indices to the dictionary. |
---|
Returns: |
If {true} is present, an integer vector containing the sorted indices to
the dictionary is returned. If {true} is not present, the sorted dictionary is returned.
|
---|
Expression: |
(sort dir predicate )
(sort dir predicate true))
|
Arguments |
Name |
Type |
Description |
Argument: | dir | Directory |
The directory to be sorted |
---|
Argument: | predicate | Word |
predicate > means sort in descending order, predicate < means sort in
ascending order |
---|
Argument: | true | Boolean |
Optional argument: If present it means to return an integer vector
containing sorted indices to the directory. |
---|
Returns: |
If {true} is present, an integer vector containing the sorted indices to
the directory is returned. If {true} is not present, the sorted directory is returned.
|
---|
Expression: |
(sort matrix predicate )
(sort matrix predicate true))
|
Arguments |
Name |
Type |
Description |
Argument: | matrix | Matrix |
The Matrix to be sorted |
---|
Argument: | predicate | Word |
predicate > means sort in descending order, predicate < means sort in
ascending order |
---|
Argument: | true | Boolean |
Optional keyword, if present, an integer Vector containing stored indices to the
Matrix to be sorted. |
---|
Returns: |
The sorted Matrix is returned.
|
---|
Expression: |
(sort nummatrix predicate )
(sort nummatrix predicate true))
|
Arguments |
Name |
Type |
Description |
Argument: | nummatrix | NumMatrix |
The NumMatrix to be sorted |
---|
Argument: | predicate | Word |
predicate > means sort in descending order, predicate < means sort in
ascending order |
---|
Argument: | true | Boolean |
Optional keyword, if present, an integer Vector containing stored indices to the
NumMatrix to be sorted. |
---|
Returns: |
The sorted NumMatrix is returned.
|
---|
Expression: |
(sort list predicate )
(sort list predicate true))
|
Arguments |
Name |
Type |
Description |
Argument: | list | List |
The List to be sorted |
---|
Argument: | predicate | Word |
predicate > means sort in descending order, predicate < means sort in
ascending order |
---|
Argument: | true | Boolean |
Optional keyword, if present, an integer Vector containing stored indices to the
List to be sorted. |
---|
Returns: |
The sorted Matrix, or the integer Vector in case the argument {true} is specified, is returned.
|
---|
Examples
Here are a number of links to Lambda coding examples which contain this instruction in various use cases.
Argument Types
Here are the links to the data types of the function arguments.
Here are also a number of links to functions having arguments with any of these data types.
|
Analytic Information Server (AIS)
AIS Component Systems
- Smartbase Engine
- QT C++ Libraries
- MySQL Relational Database
- AIS Lisp Libraries
- Rapid Analytic Demo IDE
|