Add documentation example to array.sorted() (#5475)

Co-authored-by: Malo <57839069+MDLC01@users.noreply.github.com>
This commit is contained in:
Nikolai Neff-Sarnow 2024-11-30 10:10:22 +01:00 committed by GitHub
parent d40c8ab6ab
commit 76c24ee6e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,