Sort a sequence, preferring some values
Project description
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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for prefsort-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24d6422792159b7883b5043fef2bb8a024caeac14d42dba5ef4b7c51736ff1a8 |
|
MD5 | 6b0fc913a49354f6e87fb29f320dfef8 |
|
BLAKE2b-256 | 600547d04003cbf0a136b6983df036e70112439e4252cd56411c486ea1cba3e1 |