Deciding what color is nearest to another in the digital realm is a notoriously difficult thing.
I wrote a Python script that uses a library someone developed that uses the currently most advanced color model to find nearest colors, which model does a great job sorting color. Example output is in this post of mine.
If Processing or a Processing library can do HSL sorting, that might be the best you can do for now.
I would be thrilled if a library were developed that did CIECAM02 color modeling in Processing.