Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Sort

Sorts an array in ascending order.
Read time 3 minutesLast updated 10 days ago

Definition

  • Type: Method
  • Namespace: Unity.Collections
  • Assembly: UnityEngine.ManagedKernelModule

Sort<T>(`<>*, int)

Sorts an array in ascending order.
public static void Sort<T>(T* ptr, int length) where T : unmanaged, IComparable<T>

Parameters

ptr

The array to sort.

length

The number of elements to sort in the array. Indexes greater than or equal to
length
won't be included in the sort.

Sort<T, U>(`<>*, int, T)

Sorts an array using a custom comparison.
public static void Sort<T, U>(T* ptr, int length, U comp) where T : unmanaged where U : IComparer<T>

Parameters

ptr

The array to sort.

length

The number of elements to sort in the array. Indexes greater than or equal to
length
won't be included in the sort.

comp

T
The comparison function used to determine the relative order of the elements.

Sort<T>(Span<T>)

Sorts this span in ascending order.
public static void Sort<T>(this Span<T> span) where T : unmanaged, IComparable<T>

Parameters

The span to sort.

Sort<T, U>(Span<T>, T)

Sorts this span using a custom comparison.
public static void Sort<T, U>(this Span<T> span, U comp) where T : unmanaged where U : IComparer<T>

Parameters

The span to sort.

comp

T
The comparison function used to determine the relative order of the elements.

Sort<T>(NativeArray<T>)

Sorts this array in ascending order.
public static void Sort<T>(this NativeArray<T> container) where T : unmanaged, IComparable<T>

Parameters

The array to sort.

Sort<T, U>(NativeArray<T>, T)

Sorts this array using a custom comparison.
public static void Sort<T, U>(this NativeArray<T> container, U comp) where T : unmanaged where U : IComparer<T>

Parameters

The array to sort.

comp

T
The comparison function used to determine the relative order of the elements.

Sort<T>(NativeList<T>)

Sorts this list in ascending order.
public static void Sort<T>(this NativeList<T> container) where T : unmanaged, IComparable<T>

Parameters

container

The list to sort.

Sort<T, U>(NativeList<T>, T)

Sorts this list using a custom comparison.
public static void Sort<T, U>(this NativeList<T> container, U comp) where T : unmanaged where U : IComparer<T>

Parameters

container

The list to sort.

comp

T
The comparison function used to determine the relative order of the elements.

Sort<T>(UnsafeList<T>)

Sorts this list in ascending order.
public static void Sort<T>(this UnsafeList<T> container) where T : unmanaged, IComparable<T>

Parameters

container

The list to sort.

Sort<T, U>(UnsafeList<T>, T)

Sorts the list using a custom comparison.
public static void Sort<T, U>(this UnsafeList<T> container, U comp) where T : unmanaged where U : IComparer<T>

Parameters

container

The list to sort.

comp

T
The comparison function used to determine the relative order of the elements.

Sort<T>(NativeSlice<T>)

Sorts this slice in ascending order.
public static void Sort<T>(this NativeSlice<T> container) where T : unmanaged, IComparable<T>

Parameters

The slice to sort.

Sort<T, U>(NativeSlice<T>, T)

Sorts this slice using a custom comparison.
public static void Sort<T, U>(this NativeSlice<T> container, U comp) where T : unmanaged where U : IComparer<T>

Parameters

The slice to sort.

comp

T
The comparison function used to determine the relative order of the elements.