Skip to main content

is_sorted is a tiny Python tool to check if list (or any iterable) is sorted.

  • compatible with builtin sorted function

  • can check multiple keys sorting with custom order

Installation

pip install is_sorted

Examples

A simple way to check sorting

>>> from is_sorted import is_sorted
>>> is_sorted([1, 2, 3, 4, 5, 6])
True
>>> is_sorted([1, 3, 2, 0])
False
>>> is_sorted([5, 4, 3, 2, 1], reverse=True)
True
>>> is_sorted([(1, 2), (2, 0), (3, 10), (3, 9), (4, 5)], key=lambda x: x[0])
True

Multiple keys sorting

>>> data = [(1, 2), (1, 1), (2, 3), (2, 3), (3, 5)]
>>> is_sorted(data, multi=[(lambda x: x[0], False), (lambda x: x[1], True)])
True

Release files for is-sorted 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for is-sorted 0.0.2
File Size Uploaded
is_sorted-0.0.2.tar.gz 2.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for is-sorted 0.0.2
File Interpreter ABI Platform
is_sorted-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 5.6 kB

Release files / is_sorted-0.0.2.tar.gz

Download URL is_sorted-0.0.2.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2aefc31c2ea2add7b56359a88c2415e06c2dc165820b6667d7d6d93cdc2932b8
BLAKE2b-256 checksum
How to use checksums
b412ec7dadbbd49a324e2d8190a7f644dc0568c67134ec29f2aac2bc9de6d0d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

Release files / is_sorted-0.0.2-py3-none-any.whl

Download URL is_sorted-0.0.2-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1985e0624b49d8a6996d4d200777e2a8569b9ddbcc5aa9918b94c11bf167a8e
BLAKE2b-256 checksum
How to use checksums
00a94bca7fe9ba60c4faa337e8de258ab427b3f4ff83547f11b3eca973be7c06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page