From 98bb21dff5284430cff9d954c262aa755acb3749 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 22 Oct 2004 20:15:39 +0000 Subject: [PATCH] =?utf8?q?Se=20ordenan=20discos=20por=20a=C3=B1o.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- glabels/mp3.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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) { -- 2.43.0