Sorting the Movies
To sort, use a method in the list.ss library:
(sort list less-than?)
We will sort by considering the first word of the title as a string:
(define movie-less-than?
(lambda (title1 title2)
(string<? (symbol->string (car title1))
(symbol->string (car title2)))))
While sorting, we will skip any articles at the beginning of a movie's title:
(define skip-article
(lambda (title)
(if (member (car title) '(the a an))
(cdr title)
title)))
Get a (nonsorted) list of titles without beginning articles and sort it:
(define titles-without-articles
(movies-satisfying our-movie-database
(lambda (movie) #t)
(lambda (movie)
(skip-article (movie-title movie)))))
(require (lib "list.ss"))
(sort titles-without-articles movie-less-than?)