定制 graze/sort 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

graze/sort

最新稳定版本:2.0.1

Composer 安装命令:

composer require graze/sort

包简介

A collection of array sorting transforms and functions

README 文档

README

sort

Master build: Master branch build status

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.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 6
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 19
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知