Metadata-Version: 2.4
Name: lazysort
Version: 2.0.2
Summary: LazySort is a module for retrieving elements from an unsorted dataset in sorted order by sorting only the subset containing the requested item.
Author: Fedor Pashnin
Author-email: Fedor Pashnin <2daemn+lazysort@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Project-URL: homepage, https://gitlab.com/daemn/lazysort
Description-Content-Type: text/markdown

# LazySort

LazySort provides a wrapper around any sequence with random access. It computes and sorts only the necessary chunks of data on-demand when items or slices are accessed.


# Installation

Using `uv`:
```shell
uv add lazysort
```

Or using `pip`:
```shell
pip install lazysort
```


# Usage

```python
from lazysort import LazySort

# An unsorted dataset.
data = [42, 15, 8, 23, 4, 16, 99, 51, 3]

# Wrap the dataset with LazySort.
# work_items_limit defines the maximum number of elements loaded into memory.
ls = LazySort(data, work_items_limit=4)

# Access elements as if the collection were sorted.
print(ls[0]) # Output: 3
print(ls[1]) # Output: 4
print(ls[-1]) # Output: 99

# Slicing is also fully supported.
print(tuple(ls[2:6]))

# Iteration yields elements in sorted order.
for item in ls: print(item)

# Using a custom key function and reverse sorting
complex_ls = LazySort(data, work_items_limit=4, key_fn=lambda x: x, reverse=True)
```


# Changelog

**v2.0.0**
- Stable production release with improved clustering algorithms and full test coverage.

**v1.3.0**
- Initial release featuring core lazy sorting capabilities, indexing, and key function support. It has a bug in the processing of equal values.


# License

This project is licensed under the [MIT License](LICENSE).


# Contact

[LinkedIn](https://www.linkedin.com/in/daemn/)

[GitLab](https://gitlab.com/daemn)
