# CompareTo

> Returns the sort position of this string relative to a byte sequence.

## Definition

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

## CompareTo\<T>(T, byte\*, int)

Returns the sort position of this string relative to a byte sequence.

```csharp
public static int CompareTo<T>(this ref T fs, byte* bytes, int bytesLen) where T : unmanaged, INativeList<byte>, IUTF8Bytes
```

### Parameters

**** (T): A string to compare.**** (\[byte\*]\(https\://learn.microsoft.com/dotnet/api/system.byte)): A byte sequence to compare.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of bytes in the byte sequence.

### Returns

| Type                                                       | Description                                                                       |
| ---------------------------------------------------------- | --------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | A number denoting the sort position of this string relative to the byte sequence: |

## CompareTo\<T, U>(T, T)

Returns the sort position of this string relative to another.

```csharp
public static int CompareTo<T, T2>(this ref T fs, in T2 other) where T : unmanaged, INativeList<byte>, IUTF8Bytes where T2 : unmanaged, INativeList<byte>, IUTF8Bytes
```

### Parameters

**** (T): A string to compare.**** (T): Another string to compare.

### Returns

| Type                                                       | Description                                                  |
| ---------------------------------------------------------- | ------------------------------------------------------------ |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | A number denoting the relative sort position of the strings: |
