<form action="sortieren.php" method="POST"> <input type="text" name="zahlen" /> <input type="submit" value="Do it!" /> </form> <?php $liste = explode(" ", $_POST["zahlen"]); foreach ($liste as $value) { echo $value; echo " "; } echo "<br /> <br /> sortierte Liste: "; $letztes = count($liste)-1; for ($grenze = 0; $grenze<=$letztes-1; $grenze++) { $kleinstes = $grenze; for ($i = $grenze+1; $i<=$letztes; $i++) { if ($liste[$i] < $liste[$kleinstes]) { $kleinstes = $i; } } $tauschv = $liste[$grenze]; $liste[$grenze] = $liste[$kleinstes]; $liste[$kleinstes] = $tauschv; } foreach ($liste as $value) { echo $value; echo " "; } ?>