fishingboy / external_sort
external sort PHP library
1.0.1
2026-05-24 02:57 UTC
Requires
- php: >=7.4.0
Requires (Dev)
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2026-05-24 04:26:11 UTC
README
繁體中文 | English
A PHP library for external merge sort — designed for datasets too large to sort in memory.
You can set a block_size limit: data within the limit is sorted in memory, while larger datasets are split into sorted temporary files and merged via a k-way merge.
Available on Packagist for installation via Composer.
Installation
composer require fishingboy/external_sort
Or add it manually to composer.json:
{
"require": {
"fishingboy/external_sort": "dev-master"
}
}
Usage
use fishingboy\external_sort\External_sort; $sorter = new External_sort([ 'block_size' => 1000, // max rows buffered in memory before flushing to a temp file 'result_file' => 'out.txt', // output path for the final sorted result 'data_type' => 'number', // 'number' (int cast) or 'text' (string trim) ]); $sorter->add_data($value); // accepts a single value or an array; call repeatedly $sorter->create_result(); // performs k-way merge and writes to result_file
License
This project is licensed under the MIT License.