---
title: "shuffled(using:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsarray/shuffled(using:)"
---

# shuffled(using:)

Returns a new array that lists this array’s elements in a random order, using the specified random source.

## Declaration

```swift
func shuffled(using randomSource: GKRandomSource) -> [Any]
```

## Parameters

- `randomSource`: A GameplayKit random source object.

## Return Value

Return Value A new array that lists this array’s elements in a random order.

## Discussion

Discussion Use the randomSource parameter to influence the random shuffling. For example, to reproduce a series of shuffles for testing, you can create a GKARC4RandomSource object using the seed value of a previously used random source. This method is equivalent to the GKRandomSource method arrayByShufflingObjects(in:), but as an NSArray method it preserves generic type parameters.

## See Also

### Randomly Shuffling an Array

- [shuffled()](foundation/nsarray/shuffled().md)
