Skip to main content

Sort a sequence, preferring some values

Project description

https://img.shields.io/pypi/v/prefsort.svg https://img.shields.io/travis/jonathaneunice/prefsort.svg Documentation Status Updates

Partially sort a sequence, preferring some values.

from prefsort import prefsorted
import random

seq = list('abcde')
random.shuffle(seq)

seq2 = prefsorted(seq, 'c b')
assert seq2[0] == 'c'
assert seq2[1] == 'b'
assert set(seq2) == set(seq)

Note that this doesn’t sort the majority of the sequence in the way Python’s normal list.sort() or sorted() do. It just pulls the preferred members to the front of the list.

Project details


Download files

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

Source Distribution

prefsort-0.0.1.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

prefsort-0.0.1-py2.py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page