use strict; #use warnings; my @a; my $z=0; my $i=0; my $l; my $j; my $m; open IN, "eingabe.txt"; open OUT, ">ausgabe.txt"; while() { @a[$z] = $_; $z++; } $z=$z-1; $m =int($z / 2); quick(\@a,0,$z); sub quick { my @a=$_[0]; my $l=$_[1]; my $r=$_[2]; my $t; my $v=0; if ($l<$r) { $v=@a[$r]; do { for($i=$l; @a[$i]<$v; $i++){} for($j=$r-1; @a[$j]>$v; $j--){} # $i=$l; # while(@a[$i]<$v) # { # $i=$i+1; # } # $j=$r-1; # while(@a[$j]>$v) # { # $j=$j-1; # } if ($i<$j) { $t=@a[$i]; @a[$i]=@a[$j]; @a[$i]=$t; } }while($i<$j); $t=@a[$i]; @a[$i]=@a[$r]; @a[$r]=$t; quick(\@a,$l,$i-1); quick(\@a,$i+1,$r); } print @a; } close IN; close OUT;