1 | <?php |
||
30 | class Sort |
||
31 | { |
||
32 | /** |
||
33 | * ordered list contains sorting keys |
||
34 | * |
||
35 | * @var ArrayList |
||
36 | */ |
||
37 | private $sortingKeys; |
||
38 | |||
39 | /** |
||
40 | * @var \SimpleXMLElement $node |
||
41 | */ |
||
42 | public function __construct(\SimpleXMLElement $node) |
||
52 | |||
53 | /** |
||
54 | * Function in order to sort a set of csl items by one or multiple sort keys. |
||
55 | * Sort keys are evaluated in sequence. A primary sort is performed on all items using the first sort key. |
||
56 | * A secondary sort, using the second sort key, is applied to items sharing the first sort key value. A tertiary |
||
57 | * sort, using the third sort key, is applied to items sharing the first and second sort key values. Sorting |
||
58 | * continues until either the order of all items is fixed, or until the sort keys are exhausted. Items with an |
||
59 | * empty sort key value are placed at the end of the sort, both for ascending and descending sorts. |
||
60 | * |
||
61 | * @param array $data reference |
||
62 | */ |
||
63 | public function sort(&$data) |
||
67 | |||
68 | /** |
||
69 | * Recursive function in order to sort a set of csl items by one or multiple sort keys. |
||
70 | * All items will be distributed by the value (defined in respective sort key) in an associative array (grouped). |
||
71 | * Afterwards the array will be sorted by the array key. If a further sort key exist, each of these groups will be |
||
72 | * sorted by a recursive function call. Finally the array will be flatted. |
||
73 | * |
||
74 | * @param $keyNumber |
||
75 | * @param $dataToSort |
||
76 | * @return array |
||
77 | */ |
||
78 | private function performSort($keyNumber, $dataToSort) |
||
120 | |||
121 | public function flatten(array $array) { |
||
126 | |||
127 | /** |
||
128 | * @return ArrayList |
||
129 | */ |
||
130 | public function getSortingKeys() |
||
134 | } |