Skip to main content

tool to check sorting

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for is-sorted, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size is_sorted-0.0.2-py3-none-any.whl (3.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size is_sorted-0.0.2.tar.gz (2.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page