2017 © Pedro Peláez
 

library sort

A collection of array sorting transforms and functions

image

graze/sort

A collection of array sorting transforms and functions

  • Friday, February 2, 2018
  • by graze
  • Repository
  • 19 Watchers
  • 8 Stars
  • 21,361 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 16 % Grown

The README.md

Sort

sort, (*1)

Master build: ![Master branch build status][travis-master], (*2)

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., (*3)

It can be installed in whichever way you prefer, but we recommend Composer., (*4)

{
    "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]));

The Versions

02/02 2018

dev-master

9999999-dev https://github.com/graze/sort

A collection of array sorting transforms and functions

  Sources   Download

MIT

The Requires

  • php ^5.5 | ^7.0

 

The Development Requires

collection array transform list sort order sorting ordered schwartzian

02/02 2018

dev-modernise

dev-modernise https://github.com/graze/sort

A collection of array sorting transforms and functions

  Sources   Download

MIT

The Requires

  • php ^5.5 | ^7.0

 

The Development Requires

collection array transform list sort order sorting ordered schwartzian

23/09 2014

2.0.1

2.0.1.0 https://github.com/graze/sort

A collection of array sorting transforms and functions

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

collection array transform list sort order sorting ordered schwartzian

23/09 2014

2.0.0

2.0.0.0 https://github.com/graze/sort

A collection of array sorting transforms and functions

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

collection array transform list sort order sorting ordered schwartzian

26/03 2014

1.0.1

1.0.1.0 https://github.com/graze/sort

A collection of array sorting transforms and functions

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

array transform list sort order sorting memoize ordered schwartzian

25/03 2014

1.0.0

1.0.0.0 https://github.com/graze/sort

A collection of array sorting transforms and functions

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

array transform list sort order sorting memoize ordered schwartzian