Imagine I have random colors with their hue, saturation and value. How would I make an algorithm to order those colors from red to purple so that similar colors are next to each other?
Sorting them by hue would not be enough because I could have this case :
Color 1 : Hue = 1°, Saturation = 100%, Value = 100% : Red
Color 2 : Hue = 2°, Saturation = 10%, Value = 10% : Basically black with a hint of red
Color 3 : Hue = 3°, Saturation = 100%, Value = 100% : Red but a little more orange
For this setup, I would like Color 1 and Color 3 to be next to each other
I thought about using the distance between colors with the Pythagorean theorem in 3D but I'm not sure how to make an actual algorithm with it.
Would it work to start with the lowest hue, and then finding the closest color, and then the closest to the next one ? Or would it sometimes lead to a non ideal sort for some cases ? Is it analogous to the traveling salesman problem?