routie dev init since i didn't adhere to any proper guidance up until now
This commit is contained in:
Generated
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
import { computeOrderedValue } from './compute-ordered-value.js'
|
||||
import { buildStringFormatter } from './build-string-formatter.js'
|
||||
/**
|
||||
* Compares two strings alphabetically using locale-aware comparison.
|
||||
*
|
||||
* Applies string formatting based on options (case sensitivity, special
|
||||
* characters handling) before performing the comparison.
|
||||
*
|
||||
* @param a - The first string to compare.
|
||||
* @param b - The second string to compare.
|
||||
* @param options - Comparison options.
|
||||
* @param options.specialCharacters - How to handle special characters.
|
||||
* @param options.ignoreCase - Whether to ignore case differences.
|
||||
* @param options.locales - The locale(s) to use for comparison.
|
||||
* @param options.order - The order direction ('asc' or 'desc').
|
||||
* @returns A negative number if a < b, positive if a > b, or 0 if equal.
|
||||
*/
|
||||
function compareAlphabetically(
|
||||
a,
|
||||
b,
|
||||
{ specialCharacters, ignoreCase, locales, order },
|
||||
) {
|
||||
let formatString = buildStringFormatter({
|
||||
specialCharacters,
|
||||
ignoreCase,
|
||||
})
|
||||
return computeOrderedValue(
|
||||
formatString(a).localeCompare(formatString(b), locales),
|
||||
order,
|
||||
)
|
||||
}
|
||||
export { compareAlphabetically }
|
||||
Reference in New Issue
Block a user