PHP Classes

External Sort: Sort large files similar to the UNIX sort command

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 401 All time: 6,560 This week: 455Up
Version License PHP version Categories
external-sort 1.0.0Freely Distributable5Algorithms, PHP 5, Text processing, C...


This class can sort large files similar to the UNIX sort command.

It can read the file to be sorted in small buckets associated to temporary files to not exceed the configured PHP memory limits.

The buckets are sorted individually and then merged to produce the final sorted output.

The class provides command line interface options so it can be executed as a command from a shell.

Innovation Award
PHP Programming Innovation award nominee
November 2011
Number 7
Sorting data is a relatively easy operation to implement in PHP using the many variants of PHP array sorting functions.

However, if you need to sort large amounts of data, that is not very easy, as it may exceed PHP configured memory limits.

This class implements an approach to sort large files similar to the Unix sort command.

It splits a file to be sorted in multiple chunks of limited size and then merges the sorted results into a final output file.

Manuel Lemos
Picture of Philipp Strazny
  Performance   Level  
Name: Philipp Strazny is available for providing paid consulting. Contact Philipp Strazny .
Classes: 5 packages by
Country: United States United States
Age: 57
All time rank: 1380200 in United States United States
Week rank: 307 Up35 in United States United States Up
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

  • efficiency_comparison.png
  Files folder image Files  
File Role Description
Plain text file ExternalSort.php Class the external sorting application
Accessible without login HTML file ExternalSort_about.htm Doc. explanations, examples, performance
Accessible without login Plain text file BucketCollectionTest.php Test unit tests for BucketCollection utility class
Accessible without login Plain text file ExternalSortTest.php Test unit tests for ExternalSort
Accessible without login Plain text file License Lic. Academic Free License

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,560
This week:455Up