> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/scene-fusion/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.assetsorter.md).

# Class AssetSorter

Namespace: [KS.SceneFusion.Client.Unity.Editor](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor.md)\
Assembly: KSUnity-Source.dll

IComparer for sorting assets first by type then by name.

```csharp
public class AssetSorter
```

#### Inheritance

object ← [AssetSorter](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.assetsorter.md)

## Constructors

### AssetSorter() <a href="#ks_scenefusion_client_unity_editor_assetsorter__ctor" id="ks_scenefusion_client_unity_editor_assetsorter__ctor"></a>

Constructor

```csharp
public AssetSorter()
```

## Methods

### Compare(KeyValuePair\<int, string>, KeyValuePair\<int, string>) <a href="#ks_scenefusion_client_unity_editor_assetsorter_compare_system_collections_generic_keyvaluepair_syste" id="ks_scenefusion_client_unity_editor_assetsorter_compare_system_collections_generic_keyvaluepair_syste"></a>

Compares two int+string key value pairs to see which should come first. First compares the ints, and if they are the same, compares strings.

```csharp
public int Compare(KeyValuePair<int, string> lhs, KeyValuePair<int, string> rhs)
```

#### Parameters

`lhs` KeyValuePair\<int, string>

`rhs` KeyValuePair\<int, string>

#### Returns

int

less than 0 if lhs should come first, greater than 0 if rhs should come first, and 0 if they are equal.

### Sort(Object\[], Object) <a href="#ks_scenefusion_client_unity_editor_assetsorter_sort_unityengine_object___unityengine_object" id="ks_scenefusion_client_unity_editor_assetsorter_sort_unityengine_object___unityengine_object"></a>

Sorts assets first by type then by name, keeping the main asset first. This is a stable sort--if two assets have the same type and name their order is preserved.

```csharp
public Object[] Sort(Object[] assets, Object mainAsset)
```

#### Parameters

`assets` Object\[]

assets to sort.

`mainAsset` Object

mainAsset to keep at front of array.

#### Returns

Object\[]

sorted assets.
