graze/sort
最新稳定版本:2.0.1
Composer 安装命令:
composer require graze/sort
包简介
A collection of array sorting transforms and functions
README 文档
README
This library provides a few useful functions used for sorting large arrays or
sorting where comparing array values is expensive to perform. The intention is
to provide these functions while remaining interoperable with PHP's built-in
usort functions where possible.
It can be installed in whichever way you prefer, but we recommend Composer.
{
"require": {
"graze/sort": "*"
}
}
Documentation
<?php $unsorted = [ (object) ['foo' => 1, 'bar' => 3], (object) ['foo' => 3, 'bar' => 2], (object) ['foo' => 2, 'bar' => 1], (object) ['foo' => 2, 'bar' => 2], (object) ['foo' => 3, 'bar' => 3], (object) ['foo' => 1, 'bar' => 1], (object) ['foo' => 2, 'bar' => 3], (object) ['foo' => 3, 'bar' => 1], (object) ['foo' => 1, 'bar' => 2] ]; $foo = function ($v) { return $v->foo; }; $bar = function ($v) { return $v->bar; }; // Using comparison sorting $sorted = \Graze\Sort\comparison($unsorted, [$foo, $bar]); // Using schwartzian sorting $sorted = \Graze\Sort\schwartzian($unsorted, [$foo, $bar]); // Using comparison sorting with usort $sorted = $unsorted; usort($sorted, \Graze\Sort\comparison_fn($unsorted, [$foo, $bar]));
统计信息
- 总下载量: 282.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-03-25