title: MIT Scheme List Sorted in Ascending order
body: <p>I'm taking a practice exam for a course in programming that deals with MIT Scheme. One of the questions asks:</p>
  
  <p>"Complete the procedure (in-order ls) to return the list ls, except stop just before the first value that is not <em>strictly greater</em> than the previous value in ls. In other words, in-order should return the portion of ls <em>starting from the beginning</em> that is <em>sorted in strictly increasing order</em>. Assume that ls contains only non-negative integers."</p>
  
  <p>The question then shows several examples:</p>
  
  <pre><code>(in-order '(1 2 3 4)) ; should return (1 2 3 4)
  (in-order '(1 2 3 3 4 5)) ; should return (1 2 3)
  (in-order '(3 2)) ; should return (3)
  (in-order '(3)) ; should return (3)
  </code></pre>
  
  <p>This is my attempt at a solution:</p>
  
  <pre><code>(define (in-order ls)
    (cond ((null? ls) ls)
          ((&lt; (car ls) (cadr ls)) 
           (cons (car ls) (cons (in-order (cdr ls)) ())))
          ((&gt;= (car ls) (cadr ls)) (car ls))
          (else "Nothing")))
  </code></pre>
  
  <p>It comes close to working with the 2nd and 3rd example, but outright fails with the 1st and 4th example. I know that it keeps trying to pass a null as part of the argument, but I'm unsure of how to work around this. Other than that, is there anything else that I'm getting wrong? </p>