+ $client = $this->prepare_client();
+ $listes = $client->get_lists();
+ // Default ordering is by ascending names.
+ if (is_null($order_by) || is_null($order)
+ || !in_array($order_by, array('list', 'desc', 'nbsub'))
+ || !in_array($order, array('asc', 'desc'))) {
+ $order_by = 'list';
+ $order = 'asc';
+ }
+
+ $compare = function ($a, $b) use ($order_by, $order)
+ {
+ switch ($order_by) {
+ case 'desc':
+ $a[$order_by] = replace_accent($a[$order_by]);
+ $b[$order_by] = replace_accent($b[$order_by]);
+ case 'list':
+ $res = strcasecmp($a[$order_by], $b[$order_by]);
+ break;
+ case 'nbsub':
+ $res = $a[$order_by] - $b[$order_by];
+ break;
+ default:
+ $res = 0;
+ }
+
+ if ($order == 'asc') {
+ return $res;
+ }
+ return $res * -1;
+ };
+ usort($listes, $compare);