title: Bubble Sort Algorithm - Scilab
body: <p>I'm a first year computing student and can't get my function to work properly.  I'm getting undisclosed errors and don't know why.</p>
  
  <p>I've had it working but it didn't display the list at the end or allow me to use %T and %F for my 'escape' boolean variable.</p>
  
  <p>Any thoughts?</p>
  
  <pre><code>function x=sort(n,y);
  disp("Enter numbers");
  for i = 1:n
      x(i) = input('');
  end
  
  escape = 0;
  
  if y == 1 then
      while escape == 0
          escape = 1;
          for i = 1:n
              if x(i+1) &lt; x(i) then
                  temp = x(i);
                  x(i) = x(i+1);
                  x(i+1) = temp;
                  escape = 0;
              end
          end
      end
  end
  
  if y == 2 then
      while escape == 0
          escape = 1;
          for i == 1:n
              if x{i+1} &gt; x{i} then
                  temp = x{i};
                  x{i} = x{i+1};
                  x{i+1} = temp;
                  escape = 0;
              end
          end
      end
  end
  
  disp(x(:));
  endfunction;
  
  a=input("Enter the number of values to sort: ");
  b=input("Enter 1 for ascending, 2 for descending: ")
  disp(sort(a,b));
  </code></pre>