mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Add documentation example to array.sorted()
(#5475)
Co-authored-by: Malo <57839069+MDLC01@users.noreply.github.com>
This commit is contained in:
parent
d40c8ab6ab
commit
76c24ee6e3
@ -815,6 +815,19 @@ impl Array {
|
||||
///
|
||||
/// Returns an error if two values could not be compared or if the key
|
||||
/// function (if given) yields an error.
|
||||
///
|
||||
/// To sort according to multiple criteria at once, e.g. in case of equality
|
||||
/// between some criteria, the key function can return an array. The results
|
||||
/// are in lexicographic order.
|
||||
///
|
||||
/// ```example
|
||||
/// #let array = (
|
||||
/// (a: 2, b: 4),
|
||||
/// (a: 1, b: 5),
|
||||
/// (a: 2, b: 3),
|
||||
/// )
|
||||
/// #array.sorted(key: it => (it.a, it.b))
|
||||
/// ```
|
||||
#[func]
|
||||
pub fn sorted(
|
||||
self,
|
||||
|
Loading…
x
Reference in New Issue
Block a user