Sorts colors according to the specified factor(s). The supported options are:
The factor is expected to be an array of strings with each element being a valid factor. Every key is a factor, with the sorted collection as the value in the result object.
To get all the factors in the result object pass undefined to factor.
'contrast' - Sorts colors according to their contrast value as defined by WCAG.
The contrast is tested against a comparison color which can be specified in the options object.
'lightness' - Sorts colors according to their lightness.
'chroma' - Sorts colors according to the intensity of their chroma in the colorspace specified in the options object.
'distance' - Sorts colors according to their distance.
The distance is computed from the against color token which is used for comparison for all the colors in the collection.
luminance - Sorts colors according to their relative brightness as defined by the WCAG3 definition.
The return type is determined by the type of collection:
Plain objects are returned as Map objects because they remember insertion order. Map objects are returned as is.
ArrayLike objects are returned as plain arrays. Plain arrays are returned as is.
Sorts colors according to the specified
factor(s). The supported options are:factoris expected to be an array of strings with each element being a validfactor. Every key is afactor, with the sorted collection as the value in the result object.To get all the factors in the result object pass
undefinedtofactor.'contrast'- Sorts colors according to their contrast value as defined by WCAG. The contrast is testedagainsta comparison color which can be specified in theoptionsobject.'lightness'- Sorts colors according to their lightness.'chroma'- Sorts colors according to the intensity of theirchromain thecolorspacespecified in theoptionsobject.'distance'- Sorts colors according to their distance. The distance is computed from theagainstcolor token which is used for comparison for all the colors in thecollection.luminance- Sorts colors according to their relative brightness as defined by the WCAG3 definition.The return type is determined by the type of
collection:Mapobjects because they remember insertion order.Mapobjects are returned as is.ArrayLikeobjects are returned as plain arrays. Plain arrays are returned as is.