@@ -1295,6 +1295,28 @@ are always available. They are listed here in alphabetical order.
12951295 .. versionchanged :: 3.8
12961296 The *key * can be ``None ``.
12971297
1298+ .. function :: minmax(iterable, /, *, key=None)
1299+ minmax(iterable, /, *, default, key=None)
1300+ minmax(arg1, arg2, /, *args, key=None)
1301+
1302+ Return the smallest and largest items respectively in an iterable or the smallest and largest
1303+ of two or more arguments.
1304+
1305+ If one positional argument is provided, it should be an :term: `iterable `.
1306+ The smallest and largest items in the iterable are returned. If two or more positional
1307+ arguments are provided, the smallest and largest of the positional arguments are
1308+ returned.
1309+
1310+ There are two optional keyword-only arguments. The *key * argument specifies
1311+ a one-argument ordering function like that used for :meth: `list.sort `. The
1312+ *default * argument specifies an object to return if the provided iterable is
1313+ empty. If the iterable is empty and *default * is not provided, a
1314+ :exc: `ValueError ` is raised.
1315+
1316+ If multiple items are minimal / maximal, the function returns the first one
1317+ encountered. This is consistent with other sort-stability preserving tools
1318+ such as ``(sorted(iterable, key=keyfunc)[0], sorted(iterable, key=keyfunc)[-1]) ``
1319+ and ``(heapq.nsmallest(1,iterable, key=keyfunc), heapq.nlargest(1,iterable, key=keyfunc)) ``.
12981320
12991321.. function :: next(iterator, /)
13001322 next(iterator, default, /)
0 commit comments