These functions take a palette as input, sort it either by the hue or
by the luminance, and return the result. One possibnle aplication
would be to combine "dark" and "light" palettes to generate larger
version of the RColorBrewer "Paired" palette.
D <- dark.colors(24)
L <- light.colors(24)
X <- sortByHue(c(D,L))
names(X) <- colorNames(X)
X <- X[!duplicated(names(X))]
swatch(X)
Y <- sortByLuminance(X)
swatch(Y)