lila/apps/api/src/lib/utils.ts
2026-04-30 01:13:01 +02:00

12 lines
314 B
TypeScript

export const shuffleArray = <T>(array: T[]): T[] => {
const result = [...array];
for (let i = result.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
const temp = result[i]!;
result[i] = result[j]!;
result[j] = temp;
}
return result;
};
// testing pre-commit hooks