Metadata-Version: 2.4
Name: minimindslab-key-value-sort
Version: 0.1.0
Summary: Deterministically sort flat key-value mappings by key, with optional case-insensitive ordering and stable output for reproducible config/text generation.
Author: MiniMindsLab
License: MIT
Keywords: sorting,mapping,deterministic,canonicalization,config
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# MiniMindsLab Key-Value Sort

Deterministically sort flat key-value mappings by key, with optional case-insensitive ordering and stable output for reproducible config/text generation.

## Why

When generating config files, fixtures, or canonical text, stable ordering makes diffs and hashes reliable.

## Installation

This project is a pure Python library with no runtime dependencies.

## Usage

```python
from minimindslab_key_value_sort import sort_key_value_items, sort_key_value_dict

data = {"b": 2, "A": 1, "a": 3}

items = sort_key_value_items(data)
# [('A', 1), ('a', 3), ('b', 2)]

items_ci = sort_key_value_items(data, case_insensitive=True)
# [('A', 1), ('a', 3), ('b', 2)]

ordered_dict = sort_key_value_dict(data, case_insensitive=True)
# {'A': 1, 'a': 3, 'b': 2}
```

## API

- `sort_key_value_items(mapping, case_insensitive=False)`
  - Returns a list of `(key, value)` tuples sorted deterministically.
- `sort_key_value_dict(mapping, case_insensitive=False)`
  - Returns a new dict with insertion order matching deterministic sorted order.

### Notes

- Input must be a mapping (`collections.abc.Mapping`).
- Keys must be strings.
- In case-insensitive mode, ordering is by `key.lower()` with a stable tie-breaker by original key.

## License

MIT
