---
title: "sortedArray(using:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsorderedset/sortedarray(using:)"
---

# sortedArray(using:)

Returns an array of the ordered set’s elements sorted as specified by a given array of sort descriptors.

## Declaration

```swift
func sortedArray(using sortDescriptors: [NSSortDescriptor]) -> [Any]
```

## Parameters

- `sortDescriptors`: An array of doc://com.apple.foundation/documentation/Foundation/NSSortDescriptor objects.

## Return Value

Return Value An NSArray containing the ordered set’s elements sorted as specified by sortDescriptors.

## Discussion

Discussion The first descriptor specifies the primary key path to be used in sorting the ordered set’s elements. Any subsequent descriptors are used to further refine sorting of objects with duplicate values. See NSSortDescriptor for additional information.

## See Also

### Creating a Sorted Array

- [sortedArray(comparator:)](foundation/nsorderedset/sortedarray(comparator:).md)
- [sortedArray(options:usingComparator:)](foundation/nsorderedset/sortedarray(options:usingcomparator:).md)
