//Here is the simplest way of sorting... $list = array('5','15','7','12','39','1','5'); $a; $b; for($i=0;$i