How can I modify sorting algorithm for color and sizes without hardcode?
I have a code that checks the availability of attributes. That is, if there is a black color with sizes s, l, xl and m, and there is a purple color with size s, then block unavailable size combinations for purple. However, both colors have a common size s. Also, the user can immediately select the black color on the product card and go to the detailed card where he can select other combinations of sizes and colors. And in this case, if the user selected the black color size M and went to the card, but the size s is blocked, then switching to purple will be blocked. There is a direct dependency between what the user initially selected and which common elements are unavailable for selection. I wrote code that checks the availability of colors and sizes and blocks unavailable non-common combinations, but how to get rid of the hardcode? This approach is not flexible.