<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSArray/shuffled(using:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSArray(im)shuffledArrayWithRandomSource:"
  },
  "title" : "shuffled(using:)"
}
-->

# shuffled(using:)

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

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

## Parameters

`randomSource`

A GameplayKit random source object.

## Return Value

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

## Discussion

Use the `randomSource` parameter to influence the random shuffling. For example, to reproduce a series of shuffles for testing, you can create a <doc://com.apple.documentation/documentation/GameplayKit/GKARC4RandomSource> object using the <doc://com.apple.documentation/documentation/GameplayKit/GKARC4RandomSource/seed> value of a previously used random source.

This method is equivalent to the <doc://com.apple.documentation/documentation/GameplayKit/GKRandomSource> method <doc://com.apple.documentation/documentation/GameplayKit/GKRandomSource/arrayByShufflingObjects(in:)>, but as an [`NSArray`](/documentation/Foundation/NSArray) method it preserves generic type parameters.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)