public function getFilesInFolder_sort($doc1, $doc2) { $sort = 0; $sort_config = classeurService::getContentSort(); // [colonne] => titre // [direction] => ASC switch ($sort_config['colonne']) { case 'date': if ($doc1->date_upload < $doc2->date_upload) { $sort = -1; } if ($doc1->date_upload > $doc2->date_upload) { $sort = 1; } break; case 'taille': if ($doc1->taille < $doc2->taille) { $sort = -1; } if ($doc1->taille > $doc2->taille) { $sort = 1; } break; case 'type': if ($doc1->type < $doc2->type) { $sort = -1; } if ($doc1->type > $doc2->type) { $sort = 1; } break; case 'titre': default: if ($doc1->titre < $doc2->titre) { $sort = -1; } if ($doc1->titre > $doc2->titre) { $sort = 1; } break; } if ($sort_config['direction'] == 'DESC') { $sort = -$sort; } return $sort; }