safesort: safely sort heterogeneous collections on Python 2 and 3
safesort does what it says on the box: guarantees safe sorting of arbitrary heterogeneous lists across Python 2 and Python 3:
>>> list(sorted(["a", 1, None])) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unorderable types: int() < str() >>> list(safesort(["a", 1, None)) [None, 1, 'a']
Three ordering keys are attempted for each comparison:
Object: objA > objB
Type-and-object: (type(objA).__mro__, objA) > (type(objB).__mro__, objB)
Type-and-identity: (type(objA).__mro__, id(objA)) > (type(objB).__mro__, id(objB))
This guarantees a total ordering which is:
As consistent as possible
Broadly sensible: objects with similar types will be grouped together
For example:
>>> from safesort import safesort
>>> input = ['a', set([]), [], {}, 1, None]
>>> list(safesort(input))
[None, 1, {}, [], set([]), 'a']
Installation
safesort can be installed with Python 2 or Python 3 using pip or easy_install:
$ pip install safesort - OR - $ easy_install safesort
Metadata
Release files for safesort 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| safesort-0.2.0.tar.gz | 2.5 kB | Without provenance | Details for safesort-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| safesort-0.2.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for safesort-0.2.0-py2.py3-none-any.whl |
Total release size: 6.6 kB
Release files / safesort-0.2.0.tar.gz
| Download URL | safesort-0.2.0.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6b37e6708d39072dd27316d3146d1c32fb1babdb1fd01d90961c7dc2e00dcce
|
|
BLAKE2b-256 checksum How to use checksums |
1212acc06ea4f237a8009d09b22f42bf69f9543e116e1ae87e92dd52b7c75e35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / safesort-0.2.0-py2.py3-none-any.whl
| Download URL | safesort-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e76cb7a4ab51c71229aa00798c67f27d8495f696506604a8ad2e2a6870162122
|
|
BLAKE2b-256 checksum How to use checksums |
3d882a1ae0ab8cfdcdd22e2a33b1562eade6da8c5758153f8260be08314d216e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for safesort 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.