Runtime v2.81 · Updated Sep 30, 2026

sorted

Return a new list containing all items from iterable in sorted order.

Syntax

sorted(iterable, /, *, key=None, reverse=False)

Parameters

NameDescription
iterableString | list | tuple | dict | set
Iterable input. Dictionaries sort keys.
Required · Positional only
No default
keyCallable?
One-argument callable used to compute comparison keys.
Optional · Keyword only
Default: None
reverseBoolean
Sort descending when True.
Optional · Keyword only
Default: False

Returns

list — A new sorted list. The input value is not modified.

Behavior / side effects

Return a new list containing all items from iterable in sorted order. key can compute comparison keys; reverse=True sorts descending while keeping equal-key items stable.

Execution

  • Blocking: Conditional
  • Thread safety: Use separate objects per flow
  • Parallel execution: Conditional

The operation processes values in the calling flow. A key callable also runs there and may perform waits or side effects; no asynchronous execution is implied.

Example

values = sorted([3, 1, 2])
text(str(values))

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

None