# SortJob

> Returns a job which will sort an array in ascending order.

## Definition

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

## SortJob\<T>(\`\<>\*, int)

Returns a job which will sort an array in ascending order.

```csharp
public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(T* ptr, int length) where T : unmanaged, IComparable<T>
```

### Parameters

**** (\[\<T>\*]\(./)): The array to sort.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of elements to sort in the array. Indexes greater than or equal to `length` won't be included in the sort.

### Returns

| Type                             | Description                  |
| -------------------------------- | ---------------------------- |
| SortJob\<T, DefaultComparer\<T>> | A job for sorting the array. |

### Remarks

This method does not schedule the job. Scheduling the job is left to you.

## SortJob\<T, U>(\`\<>\*, int, T)

Returns a job which will sort an array using a custom comparison.

```csharp
public static SortJob<T, U> SortJob<T, U>(T* ptr, int length, U comp) where T : unmanaged where U : IComparer<T>
```

### Parameters

**** (\[\<T>\*]\(./)): The array to sort.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of elements to sort in the array. Indexes greater than or equal to `length` won't be included in the sort.**** (T): The comparison function used to determine the relative order of the elements.

### Returns

| Type                                                                            | Description                  |
| ------------------------------------------------------------------------------- | ---------------------------- |
| [SortJob\<T, T>](/engine/6000.7/script-reference/unity/collections/sortjob2.md) | A job for sorting the array. |

### Remarks

This method does not schedule the job. Scheduling the job is left to you.

## SortJob\<T>(Span\<T>)

Returns a job which will sort this span in ascending order.

```csharp
public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(this Span<T> span) where T : unmanaged, IComparable<T>
```

### Parameters

**** (\[Span\<T>]\(https\://learn.microsoft.com/dotnet/api/system.span-1)): The span to sort.

### Returns

| Type                             | Description                   |
| -------------------------------- | ----------------------------- |
| SortJob\<T, DefaultComparer\<T>> | A job for sorting this array. |

### Remarks

This method does not schedule the job. Scheduling the job is left to you.

## SortJob\<T, U>(Span\<T>, T)

Returns a job which will sort this span using a custom comparison.

```csharp
public static SortJob<T, U> SortJob<T, U>(this Span<T> span, U comp) where T : unmanaged where U : IComparer<T>
```

### Parameters

**** (\[Span\<T>]\(https\://learn.microsoft.com/dotnet/api/system.span-1)): The span to sort.**** (T): The comparison function used to determine the relative order of the elements.

### Returns

| Type                                                                            | Description                  |
| ------------------------------------------------------------------------------- | ---------------------------- |
| [SortJob\<T, T>](/engine/6000.7/script-reference/unity/collections/sortjob2.md) | A job for sorting the array. |

### Remarks

This method does not schedule the job. Scheduling the job is left to you.

## SortJob\<T>(NativeArray\<T>)

Returns a job which will sort this array in ascending order.

```csharp
public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(this NativeArray<T> container) where T : unmanaged, IComparable<T>
```

### Parameters

**** (\[NativeArray\<T>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): The array to sort.

### Returns

| Type                             | Description                   |
| -------------------------------- | ----------------------------- |
| SortJob\<T, DefaultComparer\<T>> | A job for sorting this array. |

### Remarks

This method does not schedule the job. Scheduling the job is left to you.

## SortJob\<T, U>(NativeArray\<T>, T)

Returns a job which will sort this array using a custom comparison.

```csharp
public static SortJob<T, U> SortJob<T, U>(this NativeArray<T> container, U comp) where T : unmanaged where U : IComparer<T>
```

### Parameters

**** (\[NativeArray\<T>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): The array to sort.**** (T): The comparison function used to determine the relative order of the elements.

### Returns

| Type                                                                            | Description                  |
| ------------------------------------------------------------------------------- | ---------------------------- |
| [SortJob\<T, T>](/engine/6000.7/script-reference/unity/collections/sortjob2.md) | A job for sorting the array. |

### Remarks

This method does not schedule the job. Scheduling the job is left to you.

## SortJob\<T>(NativeList\<T>)

Returns a job which will sort this list in ascending order.

```csharp
public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(this NativeList<T> container) where T : unmanaged, IComparable<T>
```

### Parameters

**** (\[NativeList\<T>]\(/engine/6000.7/script-reference/unity/collections/nativelist1)): The list to sort.

### Returns

| Type                             | Description                  |
| -------------------------------- | ---------------------------- |
| SortJob\<T, DefaultComparer\<T>> | A job for sorting this list. |

### Remarks

When `NativeList.Length` is not known at scheduling time use `SortJobDefer` instead. This method does not schedule the job. Scheduling the job is left to you.

## SortJob\<T, U>(NativeList\<T>, T)

Returns a job which will sort this list using a custom comparison.

```csharp
public static SortJob<T, U> SortJob<T, U>(this NativeList<T> container, U comp) where T : unmanaged where U : IComparer<T>
```

### Parameters

**** (\[NativeList\<T>]\(/engine/6000.7/script-reference/unity/collections/nativelist1)): The list to sort.**** (T): The comparison function used to determine the relative order of the elements.

### Returns

| Type                                                                            | Description                  |
| ------------------------------------------------------------------------------- | ---------------------------- |
| [SortJob\<T, T>](/engine/6000.7/script-reference/unity/collections/sortjob2.md) | A job for sorting this list. |

### Remarks

When `NativeList.Length` is not known at scheduling time use `SortJobDefer` instead. This method does not schedule the job. Scheduling the job is left to you.

## SortJob\<T>(UnsafeList\<T>)

Returns a job which will sort this list in ascending order.

```csharp
public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(this UnsafeList<T> container) where T : unmanaged, IComparable<T>
```

### Parameters

**** (\[UnsafeList\<T>]\(/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafelist1)): The list to sort.

### Returns

| Type                             | Description                  |
| -------------------------------- | ---------------------------- |
| SortJob\<T, DefaultComparer\<T>> | A job for sorting this list. |

### Remarks

This method does not schedule the job. Scheduling the job is left to you.

## SortJob\<T, U>(UnsafeList\<T>, T)

Returns a job which will sort this list using a custom comparison.

```csharp
public static SortJob<T, U> SortJob<T, U>(this UnsafeList<T> container, U comp) where T : unmanaged where U : IComparer<T>
```

### Parameters

**** (\[UnsafeList\<T>]\(/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafelist1)): The list to sort.**** (T): The comparison function used to determine the relative order of the elements.

### Returns

| Type                                                                            | Description                  |
| ------------------------------------------------------------------------------- | ---------------------------- |
| [SortJob\<T, T>](/engine/6000.7/script-reference/unity/collections/sortjob2.md) | A job for sorting this list. |

### Remarks

This method does not schedule the job. Scheduling the job is left to you.

## SortJob\<T>(NativeSlice\<T>)

Returns a job which will sort this slice in ascending order.

```csharp
public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(this NativeSlice<T> container) where T : unmanaged, IComparable<T>
```

### Parameters

**** (\[NativeSlice\<T>]\(/engine/6000.7/script-reference/unity/collections/nativeslice1)): The slice to sort.

### Returns

| Type                             | Description                   |
| -------------------------------- | ----------------------------- |
| SortJob\<T, DefaultComparer\<T>> | A job for sorting this slice. |

### Remarks

This method does not schedule the job. Scheduling the job is left to you.

## SortJob\<T, U>(NativeSlice\<T>, T)

Returns a job which will sort this slice using a custom comparison.

```csharp
public static SortJob<T, U> SortJob<T, U>(this NativeSlice<T> container, U comp) where T : unmanaged where U : IComparer<T>
```

### Parameters

**** (\[NativeSlice\<T>]\(/engine/6000.7/script-reference/unity/collections/nativeslice1)): The slice to sort.**** (T): The comparison function used to determine the relative order of the elements.

### Returns

| Type                                                                            | Description                   |
| ------------------------------------------------------------------------------- | ----------------------------- |
| [SortJob\<T, T>](/engine/6000.7/script-reference/unity/collections/sortjob2.md) | A job for sorting this slice. |

### Remarks

This method does not schedule the job. Scheduling the job is left to you.
