UNPKG

scrabble-solver

Version:

Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Crossplay, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.

21 lines (15 loc) 560 B
import type { Comparator } from '@/types'; import { createStringComparator } from './createStringComparator'; import { numberComparator } from './numberComparator'; export const createComparator = <T>(locale: string): Comparator<T> => { const stringComparator = createStringComparator(locale); return (a: T, b: T): number => { if (typeof a === 'string' && typeof b === 'string') { return stringComparator(a, b); } if (typeof a === 'number' && typeof b === 'number') { return numberComparator(a, b); } return 0; }; };