# engine/conversion/comparemarkers

module

<a id="functions">

## Functions

<a id="function-compareMarkersForDowncast">

### `compareMarkersForDowncast( __namedParameters, __namedParameters ) → number` _(internal)_

Sorts markers so the downcast result is deterministic regardless of the order markers were added to the marker collection.

The sort key is the marker's range, ordered "right-to-left" through the document so that a marker's opening boundary is processed _after_ any markers nested inside it. This way the outer marker wraps the inner ones at conversion time.

Cases (positions shown as `0123456789`, sort result top-to-bottom):

1. Non-overlapping ranges — sorted by position, last range first:

   ```
   a: [--]               →   c, b, a
   b:     [--]
   c:        [--]
   ```

2. Adjacent ranges (end === start) — treated as non-overlapping:

   ```
   first:  [---]         →   third, second, first
   second:    [---]
   third:        [---]
   ```

3. Nested ranges (same start, different ends) — inner first, outer last:

   ```
   shorter: [-]          →   shorter, longer
   longer:  [---]
   ```

4. Partially overlapping ranges — sorted by start position:

   ```
   earlier: [---]        →   later, earlier
   later:     [---]
   ```

5. Identical ranges — fall back to reverse name comparison:

   ```
   alpha:   [---]        →   charlie, bravo, alpha
   bravo:   [---]
   charlie: [---]
   ```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/conversion/comparemarkers.ts#L52)

#### Parameters

* `__namedParameters: readonly [ string, ModelRange ]`
* `__namedParameters: readonly [ string, ModelRange ]`

#### Returns

* `number`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
