src/Alg/Sort/Insertion.php
public function sort( $list )
	{
//		echo "list: ".implode (" | ", $list)."<br>";
		$n	= sizeof( $list );
		for( $i=0; $i<$n; $i++ )
		{
			$temp	= $list[$i];
			$j		= $n - 1;
			while( $j>=0 && $this->moves < 100 )
			{
				if( $list[$j] > $temp )
				{
					$this->moves ++;
					$list = self::swap( $list, $j + 1, $j );
//					echo "list[$i|$j]: ".implode (" | ", $list)."<br>";
					$j--;
				}
				$this->compares ++;
			}
		}
		return $list;
	}
public function sort( $list )
	{
//		echo "list: ".implode (" | ", $list)."<br>";
		$n	= sizeof( $list );
		for( $i=0; $i<$n; $i++ )
		{
			$temp	= $list[$i];
			$j		= $n - 1;
			while( $j>=0 && $this->moves < 100 )
			{
				if( $list[$j] > $temp )
				{
					$this->moves ++;
					$list = self::swap( $list, $j + 1, $j );
//					echo "list[$i|$j]: ".implode (" | ", $list)."<br>";
					$j--;
				}
				$this->compares ++;
			}
		}
		return $list;
	}
public function sort ( $ list ) { //		echo "list: ".implode (" | ", $list)."<br>";
 $ n = sizeof ( $ list ) ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ temp = $ list [ $ i ] ; $ j = $ n - 1 ; while ( $ j >= 0 && $ this -> moves < 100 ) { if ( $ list [ $ j ] > $ temp ) { $ this -> moves ++ ; $ list = self :: swap ( $ list , $ j + 1 , $ j ) ; //					echo "list[$i|$j]: ".implode (" | ", $list)."<br>";
 $ j -- ; } $ this -> compares ++ ; } } return $ list ; }
Sorts List with Insertion Sort.
@access		public
@param		array		$list		List to sort
@return		array
Sorts List with Insertion Sort .