JS Standard LibraryPlaygroundPlayground
GitHubGitHub (opens in a new tab)
  • Introduction
    • arrIns
    • arrReplace
    • arrRm
    • bounds
    • chunk
    • compact
    • countBy
    • diff
    • drop
    • groupBy
    • intersection
    • intersperse
    • max
    • min
    • move
    • range
    • reverse
    • shuffle
    • sort
    • sortBy
    • swap
    • symDiff
    • take
    • union
    • uniq
    • isEmpty
    • isEql
    • isEqlArr
    • isNil
    • isShallowEql
    • aCompose
    • aComposeFn
    • aFilter
    • aForEach
    • aMap
    • aPipe
    • aPipeFn
    • aResolvers
    • hexToRGB
    • rgbToHex
    • compose
    • composeFn
    • noop
    • pipe
    • pipeFn
    • sleep
    • avg
    • clamp
    • divMod
    • isDisjointFrom
    • isEven
    • isOdd
    • isSubsetOf
    • isSupersetOf
    • mean
    • median
    • mode
    • percentage
    • percentageOf
    • prod
    • sum
    • isNegZero
    • isZero
    • toNum
    • clone
    • fromPath
    • get
    • has
    • merge
    • mergeAll
    • omit
    • pick
    • set
    • shallowMerge
    • shallowMergeAll
    • size
    • toPath
    • toSet
    • toUnset
    • unset
    • camelCase
    • capitalize
    • insertAt
    • isEmail
    • pascalCase
    • replaceAt
    • strReplace
    • isArr
    • isArrBuf
    • isAsyFn
    • isBigInt
    • isBlob
    • isBool
    • isDataView
    • isDate
    • isDef
    • isErr
    • isFn
    • isGenFn
    • isInfinity
    • isJSON
    • isMap
    • isNull
    • isNum
    • isObj
    • isPureObj
    • isRegEx
    • isSet
    • isStr
    • isSym
    • isTypedArr
    • isUndef
    • isWkMap
    • isWkRef
    • isWkSet

On This Page

  • Syntax
  • Examples
  • Try
  • Learn
Question? Give us feedback → (opens in a new tab)
Array
shuffle

Shuffles the given array values.

✅

Immutable: This does not mutate the given array.

Syntax

import { shuffle } from '@opentf/std';
 
shuffle<T>(arr: T[]): T[]

Examples

shuffle([]) //=> []
 
shuffle([1]) //=> [1]
 
shuffle([1, 2, 3, 4, 5]) //=> [ 2, 4, 5, 1, 3 ]
 
shuffle('Apple') //=> [ 'p', 'e', 'A', 'l', 'p' ]

Try

Learn

  • Fisher–Yates shuffle (opens in a new tab)
reversesort

MIT 2024 © Open Tech Foundation.