confused on sorting algorithm

new topic     » topic index » view thread      » older message » newer message

pls can someone tell me what will be the values of j in this code or better still explain this code to me.am a bit confused in the sorting algorithm as i try to read the program flow manually by myself but i get stuck.i know this is a simple code but am really going nuts and that's the truth

--------------------------------
function simple_sort(sequence x) 
object temp  
    for i = 1 to length(x) - 1 do 
	for j = i + 1 to length(x) do 
         ? j 
          
	    if compare(x[j],x[i]) < 0 then 
		-- swap x[j], x[i] 
		temp = x[j]     
		x[j] = x[i] 
		x[i] = temp 
	    end if 
	end for 
    end for 
    return x 
end function 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu