---
id: fast-colors.insertintosortedlist
title: insertIntoSortedList() function
hide_title: true
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[@microsoft/fast-colors](./fast-colors.md) &gt; [insertIntoSortedList](./fast-colors.insertintosortedlist.md)

## insertIntoSortedList() function

Adds a newItem to an already sorted list without needing to do a full re-sort. Higher sort priority puts the newItem closer to the start (index 0) of the list.

<b>Signature:</b>

```typescript
export declare function insertIntoSortedList(list: PixelBox[], newItem: PixelBox, sortPriority: (box: PixelBox) => number): void;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  list | [PixelBox](./fast-colors.pixelbox.md)<!-- -->\[\] |  |
|  newItem | [PixelBox](./fast-colors.pixelbox.md) |  |
|  sortPriority | (box: [PixelBox](./fast-colors.pixelbox.md)<!-- -->) =&gt; number |  |

<b>Returns:</b>

void
