From: Leandro Lucarella Date: Fri, 22 Oct 2004 20:15:39 +0000 (+0000) Subject: Se ordenan discos por año. X-Git-Tag: svn_import~71 X-Git-Url: https://git.llucax.com/personal/documentos.git/commitdiff_plain/98bb21dff5284430cff9d954c262aa755acb3749?ds=sidebyside Se ordenan discos por año. --- diff --git a/glabels/mp3.php b/glabels/mp3.php index fcafc05..a930739 100755 --- a/glabels/mp3.php +++ b/glabels/mp3.php @@ -75,7 +75,7 @@ if ($datos) { 'LINEA_ANCHO' => strlen($artista) * 2.5 + 25 / strlen($artista), 'ARTISTA' => translate($artista), )); - sort($albums); + usort($albums, 'cmp'); for ($i = 0; $i < count($albums); $i++) { // assign data $tpl->setVariable('ALBUM', translate($albums[$i])); @@ -92,6 +92,20 @@ if ($datos) { fclose($fo); } +function cmp($a, $b) { + if (preg_match('/.*\[(\d{4})\]/', $a, $ma) + and preg_match('/.*\[(\d{4})\]/', $b, $mb)) + { + if ($ma[1] == $mb[1]) return 0; + elseif ($ma[1] < $mb[1]) return -1; + else return 1; + } + else + { + strcmp($a, $b); + } +} + function translate($str) { static $tabla = array(); if (!@$tabla) {