MCPcopy
hub / github.com/tailwindlabs/tailwindcss / defaultSort

Function defaultSort

packages/tailwindcss/src/sort.test.ts:100–110  ·  view source on GitHub ↗

* This is a function that the prettier-plugin-tailwindcss would use. It would * do the actual sorting based on the classes and order we return from `getClassOrder`. * * This way the actual sorting logic is done in the plugin which allows you to * put unknown classes at the end for example.

(arrayOfTuples: [string, bigint | null][])

Source from the content-addressed store, hash-verified

98 * put unknown classes at the end for example.
99 */
100function defaultSort(arrayOfTuples: [string, bigint | null][]): string {
101 return arrayOfTuples
102 .sort(([, a], [, z]) => {
103 if (a === z) return 0
104 if (a === null) return -1
105 if (z === null) return 1
106 return bigSign(a - z)
107 })
108 .map(([className]) => className)
109 .join(' ')
110}
111
112function bigSign(value: bigint) {
113 if (value > 0n) {

Callers 1

sortClassesFunction · 0.70

Calls 1

bigSignFunction · 0.70

Tested by

no test coverage detected