> For the complete documentation index, see [llms.txt](https://alex-myznikov.gitbook.io/adsjs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alex-myznikov.gitbook.io/adsjs/api/maps/sortedmap.md).

# SortedMap

### new SortedMap()

```typescript
/**
 * Creates an instance of SortedMap.
 *
 * @param iterable Iterable of pairs to create the new map with.
 * @param compare Comparison function for key-value pairs sorting by key. Keys are compared as strings by default.
 */
constructor(iterable: Iterable<[K, V]> = [], protected compare: CompareFunc<K> = compareAsStrings)
```

### size

```typescript
/**
 * Number of key-value pairs in the map.
 *
 * @readonly
 */
get size(): number;
```

### clear()

```typescript
/**
 * Removes all key-value pairs from the map.
 */
clear(): void;
```

### delete()

```typescript
/**
 * Removes the specified (by key) key-value pair from the map.
 *
 * @param key Pair key.
 * @returns TRUE if the pair existed and has been removed, FALSE otherwise.
 */
delete(key: K): boolean;
```

### entries()

```typescript
entries(): IterableIterator<[K, V]>;
```

### findGreater()

```typescript
/**
 * Finds the leftmost key-value pair with key greater than the specified key.
 *
 * @param key Pair key.
 * @returns Key-value pair or undefined if key is the greatest or the map is empty.
 */
findGreater(key: K): [K, V] | undefined;
```

### findGreaterOrEqual()

```typescript
/**
 * Finds the leftmost key-value pair with key greater than or equal to the specified key.
 *
 * @param key Pair key.
 * @returns Key-value pair or undefined if key is the greatest or the map is empty.
 */
findGreaterOrEqual(key: K): [K, V] | undefined;
```

### findLess()

```typescript
/**
 * Finds the rightmost key-value pair with key less than the specified key.
 *
 * @param key Pair key.
 * @returns Key-value pair or undefined if key is the smallest or the map is empty.
 */
findLess(key: K): [K, V] | undefined;
```

### findLessOrEqual()

```typescript
/**
 * Finds the rightmost key-value pair with key less than or equal to the specified key.
 *
 * @param key Pair key.
 * @returns Key-value pair or undefined if key is the smallest or the map is empty.
 */
findLessOrEqual(key: K): [K, V] | undefined;
```

### findMax()

```typescript
/**
 * Finds the greatest (by key) key-value pair in the map.
 *
 * @returns Key-value pair or undefined if the map is empty.
 */
findMax(): [K, V] | undefined;
```

### findMin()

```typescript
/**
 * Finds the smallest (by key) key-value pair in the map.
 *
 * @returns Key-value pair or undefined if the map is empty.
 */
findMin(): [K, V] | undefined;
```

### findRange()

```typescript
/**
 * Returns an iterable of key-value pairs for every pair in the map with start <= key < stop.
 *
 * @param start Pair key to start from.
 * @param stop Pair key to stop on.
 * @returns Iterable iterator of key-value pairs.
 */
findRange(start: K, stop: K): IterableIterator<[K, V]>;
```

### forEach()

```typescript
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any)
```

### get()

```typescript
/**
 * Gets value of the specified (by key) key-value pair from the map. Throws an error if key not found.
 *
 * @param key Pair key.
 * @returns Pair value.
 */
get(key: K): V;
```

### has()

```typescript
has(key: K): boolean;
```

### keys()

```typescript
keys(): IterableIterator<K>
```

### isEmpty()

```typescript
/**
 * Checks whether the map is empty or not.
 *
 * @returns TRUE if the map is empty, FALSE otherwise.
 */
isEmpty(): boolean;
```

### reversed()

```typescript
/**
 * Returns an iterable of key-value pairs for every key-value pair in the map in reverse order.
 *
 * @returns Iterable iterator of key-value pairs.
 */
reversed(): IterableIterator<[K, V]>;
```

### set()

```typescript
set(key: K, value: V): this;
```

### values()

```typescript
values(): IterableIterator<V>;
```

### \[Symbol.iterator]\()

```typescript
[Symbol.iterator](): IterableIterator<[K, V]>;
```
