Sorting a list of Colors.
If two colors’ red values are the same, then the one with smaller green value appears first in the ordering. If two colors have the same red and green value, then the one with smaller blue value appears first in the ordering.
Example: let the color list be
((72 75 0) (0 0 10) (255 255 255) (0 10 10) (0 10 8)(50 100 255))
Then the procedure would return
((0 0 10) (0 10 8) (0 10 10) (50 100 255) (72 75 0) (255 255 255))
You should write a custom comparator for sort:
Then you can just pass this function to the
sortprocedure.Guile:
Chez Scheme: