vanderlee / PHP-stable-sort-functions

Stable sort variants of builtin PHP sort functions. These maintain original order if comparison values are equal.
http://vanderlee.github.io/PHP-stable-sort-functions/
33 stars 8 forks source link

PHP stable sort

Version 2.0.6 Build Status

Copyright © 2015-2018 Martijn van der Lee (http://martijn.vanderlee.com). MIT Open Source license applies.

Introduction

Class of stable sort utility methods and standalone functions. Equal values remain in the original order. Only different values are sorted.

These sort utility methods follow the same interface and have the same functionality and features as the builtin sort utility methods (except they add guaranteed sort order).

Static methods

For backwards compatibility, functions (prefixed with s) are available that utilize the utility class.

Tests

PHPUnitTest testcases are included (group stablesort) in the tests directory.

Disclaimers

Only methods that make sense for stable sorting are included, so no sort or ksort variants. If you can demonstrate the case for any missing function, please let me know and they will be included.

These are not the fastest possible implementations. In fact, I guarantee they are not. Performance has been sacrificed for compatibility with their builtin counterparts.

Changes

2.0.6

2.0.1

2.0.0

1.0.3

1.0.2

1.0.1

1.0