Array Multisort is a php class who help developers to sort multiples array by their columns.
This class is a part of the Ace Framework project.

Usage

In the exemple below, we want to sort, the lines contained in $data, by volume (ascending) and then by edition (descending).

$data = array(
    array('volume' => 67, 'edition' => 2),
    array('volume' => 86, 'edition' => 1),
    array('volume' => 85, 'edition' => 6),
    array('volume' => 98, 'edition' => 2),
    array('volume' => 86, 'edition' => 6),
    array('volume' => 67, 'edition' => 7)
);

We use our class.

$result = Ace_Utils_ArrayMultiSort::getInstance($data)
    ->addSort('volume', Ace_Utils_ArrayMultiSort::ASC)
    ->addSort('edition', Ace_Utils_ArrayMultiSort::DESC)
    ->execute();

And we have finally our result.

Array(
    [0] => Array([volume] => 67 [edition] => 7)
    [1] => Array([volume] => 67 [edition] => 2)
    [2] => Array([volume] => 85 [edition] => 6)
    [3] => Array([volume] => 86 [edition] => 6)
    [4] => Array([volume] => 86 [edition] => 1)
    [5] => Array([volume] => 98 [edition] => 2)
)

Download

Changelog

Ace Utils Multisort 1.1 - 1 july 2014
    - Update sort() method to support multiple sort