Metadata-Version: 2.4
Name: minimindslab-ini-section-order
Version: 0.1.0
Summary: Deterministically reorder INI sections and optionally keys within sections while preserving comments and formatting as much as possible.
Author: MiniMindsLab
License: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# MiniMindsLab INI Section Order

Deterministically reorder INI sections and optionally keys within sections while preserving comments and formatting as much as possible.

## Features

- Reorders sections based on an explicit section order.
- Places unspecified sections at the end, sorted deterministically by section name.
- Optionally sorts keys within sections alphabetically.
- Keeps comments and blank lines attached to their nearest logical location where possible.
- Idempotent normalization (running twice yields identical output).

## Install

This package is pure Python and standard library only.

## Usage

```python
from minimindslab_ini_section_order import normalize_ini

text = """# header
[b]
z = 2

[a]
y = 1
x = 0
"""

out = normalize_ini(text, section_order=["a", "b"], sort_keys=True)
print(out)
```

## API

### `normalize_ini(text: str, section_order: list[str] | None = None, sort_keys: bool = False) -> str`

- `text`: INI content.
- `section_order`: preferred section name order.
- `sort_keys`: when `True`, key/value lines within each section are sorted by key name while preserving the original line text.

Returns normalized INI text.
