# SortIndices

> Sorts a span of indices by comparing a read-only span of values of type T, using a custom comparer.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule

## SortIndices\<T, U>(Span\<int>, ReadOnlySpan\<T>, T)

Sorts a span of indices by comparing a read-only span of values of type T, using a custom comparer.

```csharp
public static void SortIndices<T, U>(this Span<int> indices, ReadOnlySpan<T> values, U comp) where T : unmanaged, IComparable<T> where U : unmanaged, IComparer<T>
```

### Parameters

**** (\[Span\<int>]\(https\://learn.microsoft.com/dotnet/api/system.span-1)): Indices to sort. Indices must be unique, nonnegative, and strictly less than the length of values.**** (\[ReadOnlySpan\<T>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): Values to use for sorting.**** (T): The comparison function used to determine the relative order of the elements.

## SortIndices\<T>(Span\<int>, ReadOnlySpan\<T>)

Sorts a span of indices by comparing a read-only span of values of type T, using a custom comparer.

```csharp
public static void SortIndices<T>(this Span<int> indices, ReadOnlySpan<T> values) where T : unmanaged, IComparable<T>
```

### Parameters

**** (\[Span\<int>]\(https\://learn.microsoft.com/dotnet/api/system.span-1)): Indices to sort. Indices must be unique, nonnegative, and strictly less than the length of values.**** (\[ReadOnlySpan\<T>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): Values to use for sorting.
