Thank you to both.
Below is the working script. I'm thinking there must be a shorter and maby better way, but it works.
<style type="text/css"> a:link { text-decoration: none; } table { border-collapse: collapse; } td { border: 1px dotted; } </style>
<?php
// Variables
$dir = glob("*.mp3");
$sort = $_GET['sort'];
// Functions for sorting each table column title
function sort_name($a,$b) { return $a > $b; }
function sort_size($a,$b) { return filesize($a) < filesize($b); }
function sort_time($a,$b) { return filemtime($b) - filemtime($a); }
// Checks wich table column title is selected
if ($sort=='name') { usort($dir, "sort_name"); }
elseif ($sort=='size') { usort($dir, "sort_size"); }
else { usort($dir, "sort_time"); }
// Table
echo "<table>";
echo "<tr>";
$titles = array('nr','name','size','date');
foreach($titles as $title) {
if ($title==$sort) { echo "<td bgcolor=lightgreen> <b><a href=index.php?sort=$title>".ucfirst($title)."</a></b> </td>"; }
elseif ($title=='nr') { echo "<td bgcolor=lightblue> <a href=./>".ucfirst($title)."</a> </td>"; }
elseif ($title=='time'){ echo "<td bgcolor=lightblue> ".ucfirst($title)." </td>"; }
else { echo "<td bgcolor=lightblue> <a href=index.php?sort=$title>".ucfirst($title)."</a> </td>"; }
}
echo "</tr>";
// Table content
for($i=0; $i<count($dir); $i++) {
if(date("Y", filemtime($dir[$i])) == 2015) {
echo "<tr>";
echo "<td style='background-color:#fc0'> " . $i . " </td>";
echo "<td style='background-color:#fc0'> <a href=" . rawurldecode($dir[$i]) . ">" . $dir[$i] . "</a> </td>";
echo "<td style='background-color:#fc0'> " . round(filesize($dir[$i])/(1024)/(1024),1) . " MB </td>";
echo "<td style='background-color:#fc0'> " . date("d.m.Y", filemtime($dir[$i])) . "<sub> - " .date("H:i:s", filemtime($dir[$i])) . "</sub> </td>";
echo "</tr>";
}
elseif(date("Y", filemtime($dir[$i])) == 2014) {
echo "<tr>";
echo "<td style='background-color:#fc9'> " . $i . " </td>";
echo "<td style='background-color:#fc9'> <a href=" . rawurldecode($dir[$i]) . ">" . $dir[$i] . "</a> </td>";
echo "<td style='background-color:#fc9'> " . round(filesize($dir[$i])/(1024)/(1024),1) . " MB </td>";
echo "<td style='background-color:#fc9'> " . date("d.m.Y", filemtime($dir[$i])) . "<sub> - " .date("H:i:s", filemtime($dir[$i])) . "</sub> </td>";
echo "</tr>";
}
elseif(date("Y", filemtime($dir[$i])) == 2013) {
echo "<tr>";
echo "<td style='background-color:#fcf'> " . $i . " </td>";
echo "<td style='background-color:#fcf'> <a href=" . rawurldecode($dir[$i]) . ">" . $dir[$i] . "</a> </td>";
echo "<td style='background-color:#fcf'> " . round(filesize($dir[$i])/(1024)/(1024),1) . " MB </td>";
echo "<td style='background-color:#fcf'> " . date("d.m.Y", filemtime($dir[$i])) . "<sub> - " .date("H:i:s", filemtime($dir[$i])) . "</sub> </td>";
echo "</tr>";
}
elseif(date("Y", filemtime($dir[$i])) == 2010) {
echo "<tr>";
echo "<td style='background-color:#def'> " . $i . " </td>";
echo "<td style='background-color:#def'> <a href=" . rawurldecode($dir[$i]) . ">" . $dir[$i] . "</a> </td>";
echo "<td style='background-color:#def'> " . round(filesize($dir[$i])/(1024)/(1024),1) . " MB </td>";
echo "<td style='background-color:#def'> " . date("d.m.Y", filemtime($dir[$i])) . "<sub> - " .date("H:i:s", filemtime($dir[$i])) . "</sub> </td>";
echo "</tr>";
}
elseif(date("Y", filemtime($dir[$i])) == 2008) {
echo "<tr>";
echo "<td style='background-color:#add'> " . $i . " </td>";
echo "<td style='background-color:#add'> <a href=" . rawurldecode($dir[$i]) . ">" . $dir[$i] . "</a> </td>";
echo "<td style='background-color:#add'> " . round(filesize($dir[$i])/(1024)/(1024),1) . " MB </td>";
echo "<td style='background-color:#add'> " . date("d.m.Y", filemtime($dir[$i])) . "<sub> - " .date("H:i:s", filemtime($dir[$i])) . "</sub> </td>";
echo "</tr>";
}
else {
echo "<tr>";
echo "<td> " . $i . " </td>";
echo "<td> <a href=" . rawurldecode($dir[$i]) . ">" . $dir[$i] . "</a> </td>";
echo "<td> " . round(filesize($dir[$i])/(1024)/(1024),1) . " MB </td>";
echo "<td> " . date("d.m.Y", filemtime($dir[$i])) . "<sub> - " .date("H:i:s", filemtime($dir[$i])) . "</sub> </td>";
echo "</tr>";
}}
echo "</table><br>";
?>