V3g3t4 for the rescue



PHP Code: 
        <?php
        
if (isset($_REQUEST['submit'])) {
            
$data $_POST['data'];
            
$data explode("\n"$data);
            
sort($data);

            
$i=0;
            echo 
"<br />Input data:<br />";
            foreach (
$data as $repre) {
                echo 
$repre '<br />';
                
$test[$i] = pathinfo(pathinfo($data[$i],PATHINFO_FILENAME),PATHINFO_FILENAME);
                
$i++;
            }

            echo 
"<br />Sorted data:<br />";
            
$unique array_unique($test);
            
            foreach(
$unique as $v3g){
               if(
$v3g){
                   foreach(
$data as $repre)
                       if(
strpos($repre,$v3g)) echo $repre."<br />";
               }
               echo 
"<br />";
            }
        }
        
?>
Thanks to lifetalk for making the form . Hope that helps!

used two pathinfo_filenames just for the lulz! naaah, it's to get the actual filename, use explode if you want.