合同小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
554 B

  1. // @ts-nocheck
  2. /**
  3. * 使 Fisher-Yates
  4. * @description
  5. * @param arr
  6. * @returns
  7. */
  8. export function shuffle<T>(arr : T[]) : T[] {
  9. for (let i = arr.length - 1; i > 0; i--) {
  10. const j = Math.floor(Math.random() * (i + 1))
  11. const temp = arr[i]
  12. arr[i] = arr[j]
  13. arr[j] = temp
  14. }
  15. return arr
  16. }