12 lines
314 B
TypeScript
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
|