---
title: "moveSubranges(_:to:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/dictionary/values-swift.struct/movesubranges(_:to:)"
---

# moveSubranges(_:to:)

Moves the elements in the given subranges to just before the element at the specified index.

## Declaration

```swift
@discardableResult mutating func moveSubranges(_ subranges: RangeSet<Self.Index>, to insertionPoint: Self.Index) -> Range<Self.Index>
```

## Parameters

- `subranges`: The subranges of the elements to move.
- `insertionPoint`: The index to use as the destination of the elements.

## Return Value

Return Value The new bounds of the moved elements.

## Discussion

Discussion This example finds all the uppercase letters in the array and then moves them to between "i" and "j". var letters = Array("ABCdeFGhijkLMNOp") let uppercaseRanges = letters.indices(where: { $0.isUppercase }) let rangeOfUppercase = letters.moveSubranges(uppercaseRanges, to: 10) // String(letters) == "dehijABCFGLMNOkp" // rangeOfUppercase == 5..<14 note: O(n log n) where n is the length of the collection.
