* 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][])
| 98 | * put unknown classes at the end for example. |
| 99 | */ |
| 100 | function 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 | |
| 112 | function bigSign(value: bigint) { |
| 113 | if (value > 0n) { |
no test coverage detected