Find the bug in the code snippet below and fix it. Explain what this code does and what the O() ("Big Oh" notation) is.

for ($i=0,$j=count($list);$i<$j; ++$i) {
	for ($n=0,$m=count($list);$n<$m;++$n) {
		if ($list[$n]>$list[$n+1]) {
			$tmp=$list[$i];
			$list[$n]=$list[$n+1];
			$list[$n+1]=$tmp;
		}
	}
}
array(5) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) } 1
2
2
2
3


1
1




array(8) { [0]=> NULL [1]=> NULL [2]=> NULL [3]=> NULL [4]=> NULL [5]=> NULL [6]=> NULL [7]=> NULL }