sorted() — Expert Examples
Returns a new sorted list from any iterable
sorted() performance and internals
Performance characteristics and CPython implementation details.
python
# sorted() internals import dis def using_sorted(): return sorted([3,1,2]) # Bytecode analysis dis.dis(using_sorted) # Check if it's truly built-in import builtins print(f"\nsorted is builtin: {hasattr(builtins, 'sorted')}") print(f"Type: {type(builtins.sorted)}")
Understanding the internal implementation helps optimize hot paths in performance-critical code.
Want to try these examples interactively?
Open Expert Playground