Skip to main content

A small utility for sorting lists of dictionaries by dictionary key

Project description

Keysort is small utility for sorting lists of dictionaries by dictionary key.!-1EAEDB.svg


>>> from keysort import keysort
>>> my_list = [{'code': 'beta',    'number': 3},
               {'code': 'delta',   'number': 2},
               {'code': 'alpha',   'number': 0},
               {'code': 'beta',    'number': 2},
               {'code': 'charlie', 'number': 1}]
>>> keysort(my_list, ['code', 'number'])
[{'code': 'alpha',   'number': 0},
 {'code': 'beta',    'number': 2},
 {'code': 'beta',    'number': 3},
 {'code': 'charlie', 'number': 1},
 {'code': 'delta',   'number': 2}]
>>> keysort(my_list, ['number', 'code'])
[{'code': 'alpha',   'number': 0},
 {'code': 'charlie', 'number': 1},
 {'code': 'beta',    'number': 2},
 {'code': 'delta',   'number': 2},
 {'code': 'beta',    'number': 3}]


pip install keysort


Contributions of all sorts are welcome, be they bug reports, patches, or even just feedback. Creating a new issue or pull request is probably the best way to get started.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

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

Keysort-0.1.3.tar.gz (1.8 kB view hashes)

Uploaded Source

Built Distribution

Keysort-0.1.3-py3-none-any.whl (3.2 kB view hashes)

Uploaded 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