## List functions

Several functions for handling lists are contained in the `lib` list.

```lib.sort(`list`)
```

This function sorts its list argument by keys. The keys are compared in the same way as with the comparison operators. The values themselves are not sorted, and their order is not changes if they have the same keys.

````Yewslip> `print lib.sort([`c = 1, `a = 2, `b = 3, 0 = 0])
```[0 = 0, a = 2, b = 3, c = 1]
```
`Yewslip> `print lib.sort([`z = 3, 2, 1])
```[1, 2, z = 3]
```
`Yewslip> `print lib.keys(lib.sort([*[7, 3, 2, 42, 5, 11] = nil]))
```[2, 3, 5, 7, 11, 42]
```
```
```lib.sum(`value`, ...)
```

This function returns the sum of its arguments. If an arguments is a list, each of its elements is summed separately.

````Yewslip> `print lib.sum(1, 2, [3, 4, 5])
```15
```
`Yewslip> `print lib.sum(["forty", "-", "two"])
```forty-two
```
```
```lib.keys(`list`, ...)
```

This function returns the keys of a list. If several arguments are given, the function is applied to each separately and a list of results is returned.

````Yewslip> `print lib.keys([0, `a = 1, `b = 2, `c = 3])
```[(nil), a, b, c]
```
```

The same effect can be achieved using the list for syntax.

````Yewslip> `print [key for key = nil in [0, `a = 1, `b = 2, `c = 3]]
```[(nil), a, b, c]
```
```
```lib.apply(`function`, `list`)
```

This function applies `function` to each element of `list` and returns the results. Each list element can be a single argument or a list of arguments to the function.

````Yewslip> `print lib.apply(lib.sum, [1, [2, 3], ["a", "b"]])
```(nil)
```
```

The same effect can be achieved using the list for syntax.

````Yewslip> `print [lib.sum(*item) for item in [1, [2, 3], ["a", "b"]]]
```[1, 5, ab]
```
```