How to sort the list?
For example, to ensure a sequential order of values in a list composed of two lists:
=: listSort(list: $list; type: "string"; direction: "asc")
list: listAdd(list: $list_1; list: $list_2)
list_1: selectList(table: 'table_1'; field: 'unical_number'; where: 'status' != "")
list_2: selectList(table: 'table_2'; field: 'unical_number'; where: 'status' != "")
// Note that in type you need to specify the type of values, and in direction the sorting direction.
Such a case is possible but redundant:
=: listSort(list: $list; type: "number"; direction: "asc")
list: selectList(table: 'table'; field: 'unical_number'; where: 'status' != "")
// Here the database works first, and then the web server
Better this way:
=: selectList(table: 'table'; field: 'unical_number'; where: 'status' != ""; order: 'unical_number' asc)
// Here only the database works
How to sort the rowlist?
In this case, there are two additional parameters. In key we specify that we are using item, and in item — which one exactly.
=: listSort(list: $rowlist; type: "number"; direction: "asc"; key: "item"; item: "price")
rowlist: selectRowList(table: 'table'; field: 'num'; field: 'price'; where: 'status' = 4)
But in fact, you can specify the name of the item directly in the key parameter:
=: listSort(list: $rowlist; type: "number"; direction: "asc"; key: "price")
rowlist: selectRowList(table: 'table'; field: 'num'; field: 'price'; where: 'status' = 4)
How do I filter the list?
Very similar to the sorting function listFilter.
=: listFilter(list: $list; key: "value" > 1000)
list: selectList(table: 'table'; field: 'price')
In key for list, you can choose to filter by values — value or by keys — key.
How do I filter the rowlist?
Specify the column to filter by in key:
=: listFilter(list: $rowlist; key: "price" > 1000)
rowlist: selectRowList(table: 'table'; field: 'num'; field: 'price'; where: 'status' = 4)
Is it possible to filter the list by several conditions?
This is done sequentially:
=: listFilter(list: $filter_1; key: "type" = 2)
filter_1: listFilter(list: $rowlist; key: "price" > 1000)
rowlist: selectRowList(table: 'table'; field: 'type'; field: 'price'; where: 'status' = 4)
Or using the multiple key parameter (this option is faster):
=: listFilter(list: $rowlist; key: "price" > 1000; key: "type" = 2)
rowlist: selectRowList(table: 'table'; field: 'type'; field: 'price'; where: 'status' = 4)
Are the keys of the list saved when it is sorted?
No. It results in a new list where the keys start from 0.
Are the list keys preserved when it is filtered?
No. It results in a new list where the keys start from 0.
When is it important to use skip: true when working with rowList?
If you have a heterogeneous rowlist and a certain row lacks the key by which filtering is performed, the function will return an error.
skip: true indicates that the error should not be returned — the row should be excluded from the range and the process should continue.
Is it possible to sort or filter the row?
Yes. In this case, the keys are preserved. In the case of sort, they are arranged in the desired order, and in the case of filter, only those that meet the conditions remain.
If you just want to remove some keys from row and you know them, use rowKeysRemove.