For posterity, it's called "stupid".. could easily be replaced by a normal array.reduce( merge ) type of function, I just was too blinded by stupidity to see it.
That does away with the need to split into tokens, sort and reassemble..
I would thought even more useful is assign powers of two to each colour/band (1, 2, 4, 8...) so that you know which bands were in and out of play, in case you went to more of them and wanted to extract more complicated data.