# `GSFont sortGlyphs:withList:`

*Instance Method*

Sorts a mutable glyph array using a glyph-name order list and glyph metadata.

## Declaration

```swift
func sortGlyphs(_ glyphs: NSMutableArray, withList nameList: [String]?)
```

```objc
- (void) sortGlyphs:(NSMutableArray<GSGlyph *> *) glyphs withList:(NSArray<NSString *> *) nameList;
```

```python
sortGlyphs_withList_(glyphs: list[GSGlyph], nameList: list[str])
```

## Parameters

- `glyphs` — A mutable array of glyphs to sort in place.
- `nameList` — Glyph names that should be ordered before the standard metadata order, or `nil` to use only the standard metadata order.

## Discussion

Glyphs not listed in `nameList` are ordered by the standard glyph sort descriptor.

This low-level method mutates `glyphs`. It does not perform undo registration or font change notifications.

## See Also

### Glyph Ordering and Caches

- [`GSFont.keepAlternatesTogether`](/Core/GlyphsCore/GSFont/keepAlternatesTogether) — Keeps alternate glyphs next to their base glyph when sorting glyphs.
- [`GSFont sortGlyphs`](/Core/GlyphsCore/GSFont/sortGlyphs) — Sorts the font’s glyphs using the font glyph order and glyph metadata.
- [`GSFont resetCache`](/Core/GlyphsCore/GSFont/resetCache) — Invalidates the glyph name and identifier lookup caches.

