Python code conversion to processing Java

Thank you again for both answers, still confused.
Python seems to have very elegant and short ways.

I had the python code running in an atom in python mode. But I need it in processing java, as I plan to use the sorted colors for other things.

I will try to figure out the lambda sorting line. This could be big portion of code in processing.
Lucky python users…

will have to dig in the Python docs.