push @rand_sorted, splice(@array,rand(@array),1) while @array;