# SortByPublic<T extends Declaration> extension

Extension providing sorting capabilities for collections of Declaration objects.

Enables declarative sorting of reflection metadata by visibility and origin. Particularly useful when presenting API documentation or generating code.

{@template sort_by_public_extension_features}

## Sorting Features

- Public-first ordering
- Synthetic-last ordering
- Combined visibility/origin sorting
- Stable sorting (preserves original order for equal elements)

## Example Usage

    final declarations = library.getAllDeclarations();

    // Simple public-first sort
    final publicFirst = declarations.sortedByPublicFirst();

    // Combined sort
    final organized = declarations.sortedByPublicFirstThenSyntheticLast();

{@endtemplate}

on
  - Iterable<T>

## Methods

sortedByPublicFirst() → List<T>

  Available on Iterable<T>, provided by the SortByPublic extension

  Sorts declarations with public visibility before private ones.
sortedByPublicFirstThenSyntheticLast() → List<T>

  Available on Iterable<T>, provided by the SortByPublic extension

  Sorts declarations with public visibility first and synthetic declarations last.