Documentation

ArraySortHelper
in package

Helper class for sorting arrays on arbitrary criteria for usort/uasort.

Copyright 2003-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Tags
author

Marko Djukic marko@oblo.com

author

Jan Schneider jan@horde.org

author

Michael Slusarz slusarz@horde.org

category

Horde

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Table of Contents

$key  : string
The array key to sort by.
compare()  : int
Compare two associative arrays by the array key defined in self::$key.
compareKeys()  : int
Compare array keys case insensitively for uksort.
reverseCompare()  : int
Compare, in reverse order, two associative arrays by the array key defined in self::$key.
reverseCompareKeys()  : int
Compare, in reverse order, array keys case insensitively for uksort.

Properties

Methods

compare()

Compare two associative arrays by the array key defined in self::$key.

public compare(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
$a : array<string|int, mixed>
$b : array<string|int, mixed>
Return values
int

Returns < 0 if string1 is less than string2; > 0 if string1 is greater than string2, and 0 if they are equal.

compareKeys()

Compare array keys case insensitively for uksort.

public compareKeys(scalar $a, scalar $b) : int
Parameters
$a : scalar

TODO

$b : scalar

TODO

Return values
int

Returns < 0 if string1 is less than string2; > 0 if string1 is greater than string2, and 0 if they are equal.

reverseCompare()

Compare, in reverse order, two associative arrays by the array key defined in self::$key.

public reverseCompare(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
$a : array<string|int, mixed>

TODO

$b : array<string|int, mixed>

TODO

Return values
int

Returns < 0 if string1 is less than string2; > 0 if string1 is greater than string2, and 0 if they are equal.

reverseCompareKeys()

Compare, in reverse order, array keys case insensitively for uksort.

public reverseCompareKeys(scalar $a, scalar $b) : int
Parameters
$a : scalar

TODO

$b : scalar

TODO

Return values
int

Returns < 0 if string1 is less than string2; > 0 if string1 is greater than string2, and 0 if they are equal.

Search results