---
title: "arrayByShufflingObjects(in:)"
framework: gameplaykit
role: symbol
role_heading: Instance Method
path: "gameplaykit/gkrandomsource/arraybyshufflingobjects(in:)"
---

# arrayByShufflingObjects(in:)

Returns an array whose contents are the same as those of the specified array, but in a random order determined by the random source.

## Declaration

```swift
func arrayByShufflingObjects(in array: [Any]) -> [Any]
```

## Parameters

- `array`: An array of objects.

## Return Value

Return Value An array whose contents have been randomly shuffled.

## Discussion

Discussion Use this method with an instance of GKRandomSource (or of one of its subclasses) to randomly rearrange the contents of an array. For example, in a card game you might use this method to randomize an array of card objects.
