[Solved] Sorting program in ruby [closed]


if unsorted[0] <<== unsorted[1] then numsmall = unsorted[a] 
               ^
(eval):51: syntax error, unexpected kTHEN, expecting kEND

That little ^ points to first problem here. <<== is not a legal operator in ruby, hence the syntax error. Perhaps you mean “less than or equal to” which is <=?

if unsorted[a] <= unsorted[b]

Also, indentation will help you understand the flow better, try rewriting that like this:

if unsorted[a] <= unsorted[b]
  numsmall == unsorted[a]
else
  numsmall = unsorted[b]
end

1

solved Sorting program in ruby [closed]