So I need to write a procedure to organize a list. Since its hard to explain here is the example:
List:
((72 75 0) (0 0 10) (255 255 255) (0 10 10) (0 10 8)(50 100 255))

Return:
((0 0 10) (0 10 8) (0 10 10) (50 100 255) (72 75 0) (255 255 255))

procedure is called (sort-pts color-list)

first you organize it by the first number in the pair, if those are equal you look at the second number in the pair, then if those are equal you look at the third number in the pair.
Although I am really struggling with the whole thing the main concept is how do you remake the list in the procedure.

Thanks

You need to write a lambda (you can either name one or use letrec) to compare two colors (proper lists of three numeric elements). Once done that you can sort your colors any of the usual ways.

Remember, you can build your list by adding elements either at the front or at the back. So a list like:
(1 9 7 2)
can be sorted: [b]([/b]sort '(1 9 7 2)[b])[/b] 1 (9 7 2) --> (1 < 9) --> (cons 1 [b]([/b]sort '(9 7 2)[b])[/b]) 9 (7 2) --> (9 > 7) --> (cons [b]([/b]sort '(7 2)[b])[/b] 9) 7 (2) --> (7 > 2) --> (cons [b]([/b]sort '(2)[b])[/b] 7)) 2 () --> 2 producing the result: (1 . ((2 . 7) . 9)) Now just flatten the pairs into a proper list and you are set.

(This is just one way to do it.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.