This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Sort terms according to German DIN.

Project Description

Sort terms according to German DIN 5007.

| 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.


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")

Variants are defined as constants:

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

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

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

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


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']


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

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


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.
Release History

Release History

This version
History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
dinsort-0.2-py2.py3-none-any.whl (6.6 kB) Copy SHA256 Checksum SHA256 3.4 Wheel Oct 14, 2015
dinsort-0.2.tar.gz (12.6 kB) Copy SHA256 Checksum SHA256 Source Oct 14, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting