Skip to main content

dinsort

Sort terms according to German DIN 5007.

Build Status | sources | issues

Little Python library to support sorting of terms according to DIN (German Standards Institute) standard 5007.

This standard describes how to sort german terms alphabtically. It provides two variants:

  • Variant 1:

    • 'ä' equals 'a'

    • 'ß' equals 'ss'

    • …

  • Variant 2:

    • 'ä' equals 'ae'

    • 'ß' equals 'ss'

    • …

In both variants other diacritics are removed. So 'é' and 'ç' become 'e' and 'c' respecively.

Usage

dinsort is a Python library.

Normalizing Terms

Main function is dinsort.normalize. It generates a normalized form of any string term given:

>>> from dinsort import normalize
>>> normalize("Löblich")
'loblich'

Variants are defined as constants:

>>> from dinsort import VARIANT1, VARIANT2
>>> normalize("Müßig", variant=VARIANT1)
'mussig'

>>> normalize("Müßig", variant=VARIANT2)
'muessig'

Terms are normalized to lower-case by default. You can request case-sensitiveness:

>>> normalize("Maße", case_sensitive=True)
'Masse'

Sorting

Normalized terms can easily be used for sorting lists of terms:

>>> sorted(["fas", "fair", "fär"], key=lambda x: normalize(x))
['fair', 'fär', 'fas']

We provide a shortcut to avoid (sometimes not easy to read) lambda statements with normalize in your code. Use sort_func for that:

>>> from dinsort import sort_func
>>> sorted(["fas", "fair", "fär"], key=sort_func())
['fair', 'fär', 'fas']

The sort_func accepts the keywords of normalize:

>>> sorted(["Muße", "muß"], key=sort_func())
['muß', 'Muße']

>>> sorted(["Muße", "muß"], key=sort_func(case_sensitive=True))
['Muße', 'muß']

>>> sorted(["far", "fähre"], key=sort_func())
['fähre', 'far']

>>> sorted(["far", "färe", "fast"], key=sort_func())
['far', 'färe', 'fast']

>>> sorted(["far", "färe", "fast"], key=sort_func(variant=VARIANT2))
['färe', 'far', 'fast']

Install

User Install

The latest release of dinsort can be installed via pip:

$ pip install dinsort

The exact way depends on your operating system.

Developer Install

Developers clone the sources from github:

$ git clone https://github.com/ulif/dinsort.git

Create a virtual env (Python versions >= 2.6 supported):

$ cd dinsort
$ virtualenv py27
$ source py27/bin/activate

and install dependencies:

(py27) python setup py dev

You can run tests with py.test:

(py27) py.test

or with tox:

(py27) pip install tox
(py27) tox

Changes

0.2 (2015-10-14)

  • Add sort_func. It is as shortcut for lambda expressions with normalize.

  • Support pypy officially.

0.1 (2015-10-13)

  • Initial version.

Metadata

Release files for dinsort 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 dinsort 0.2
File Size Uploaded Provenance Actions
dinsort-0.2.tar.gz 12.6 kB Without provenance Details for dinsort-0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dinsort 0.2
File Interpreter ABI Platform Actions
dinsort-0.2-py2.py3-none-any.whl Python 3, Python 2 none any Details for dinsort-0.2-py2.py3-none-any.whl

Total release size: 19.1 kB

Release files / dinsort-0.2.tar.gz

Download URL dinsort-0.2.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
18a15223cb1e27ac3e73d5de41e08fe8d47dc85ee9feeeea8177b867033ca76c
BLAKE2b-256 checksum
How to use checksums
ccb218ff2e44fe0cb7e1e7955229f62904c299674b7b9ef6500255951ae793b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / dinsort-0.2-py2.py3-none-any.whl

Download URL dinsort-0.2-py2.py3-none-any.whl
Size 6.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9649c8ab7def8c16aa46fa066beba3516271f921620030f0440bd749130a104c
BLAKE2b-256 checksum
How to use checksums
d931ab178c5108772b326acf61b54546aa54e39c77e1c5129f9e70723384dc50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for dinsort 0.2

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.

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files No provenance

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