From 875a4331825b2e27641a130a4bbb8ece9d669ba5 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Mon, 28 Nov 2022 14:16:51 +0100 Subject: [PATCH] ubuiltins: Document sorted. --- src/ubuiltins/__init__.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ubuiltins/__init__.py b/src/ubuiltins/__init__.py index a78a82f..e8f6d3f 100644 --- a/src/ubuiltins/__init__.py +++ b/src/ubuiltins/__init__.py @@ -988,7 +988,20 @@ class slice: def sorted(iterable: Iterable, key=None, reverse=False) -> List: """ - Returns a new sorted list from the items in ``iterable``. + Sorts objects. + + Arguments: + iterable (iter): Objects to be sorted. This can also be a generator that + yield a finite number of objects. + key (callable): Function ``def(item) -> int`` that maps an object to a + numerical value. This is used to figure out the order of the sorted + items. + reverse (bool): Whether to sort in reverse, putting the highest value + first. + + + Returns: + A new list with the sorted items. """