imsamurai/arraysort
Composer 安装命令:
composer require imsamurai/arraysort
包简介
CakePHP utility for sorting arrays by multiple fields
README 文档
README
Check out ArraySort API Documentation
Abstract
Installation
cd my_cake_app/app
git clone git://github.com/imsamurai/cakephp-arraysort-utility.git Plugin/ArraySort
or if you use git add as submodule:
cd my_cake_app
git submodule add "git://github.com/imsamurai/cakephp-arraysort-utility.git" "app/Plugin/ArraySort"
then add plugin loading in Config/bootstrap.php
CakePlugin::load('ArraySort');
Usage
In any place of your code:
App::uses('ArraySort', 'ArraySort.Utility'); $sorted_array = ArraySort::multisort($array, $params);
where $array is array to sort,
$params can be string ('asc' or 'desc') or array like this:
$params = array( <field1> => <direction>, <field2> => <direction2>, ... );
For example:
$params = array( 'rank' => 'desc', 'created' => 'asc' );
With this $params method will sort $array by comparing each elements firstly by rank field, if they have equal rank then sort by created field.
统计信息
- 总下载量: 3.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-02-06