# rx9agh/sorttestfile architecture

> Architecture diagram of the GitHub repository rx9agh/sorttestfile, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rx9agh/sorttestfile
- Repository: https://github.com/rx9agh/sorttestfile

## Overview

This is a C# large-file text sorter: the console entry point reads a file, configures column ordering, and invokes an external merge sort that splits the input into chunks, sorts runs, and merges them to an output stream. The README also describes a test-file generator, but no generator implementation appears in the supplied tree; benchmark code is excluded as evaluation machinery. The excerpts show the sorter’s core stages, but omit some orchestration details, so the graph limits connections to relationships visible in the entry point or excerpts.

Main entry points: [`src/SortTestFile/ExternalMergeSorter.cs`](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorter.cs) (Merge sorter), [`src/SortTestFile/Program.cs`](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/Program.cs) (Console runner), [`src/SortTestFile/ColumnSorter.cs`](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ColumnSorter.cs) (Column comparer), [`src/SortTestFile/ExternalMergeSorterOptions.cs`](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorterOptions.cs) (Sort options)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_console["Console runner<br/>[Program.cs]"]
end

subgraph group_sorting["External sorting"]
  node_settings["Sort options"]
  node_sorter["Merge sorter"]
  node_chunks["Chunk splitting"]
  node_run_sort["Run sorting"]
  node_merge["Run merging"]
  node_row_cursor["Merge row cursor<br/>[Row.cs]"]
  node_temp_files["Temporary runs"]
end

subgraph group_ordering["Ordering rules"]
  node_comparer["Column comparer<br/>[ColumnSorter.cs]"]
end

node_user(("Operator"))
node_source["Input file"]
node_output["Sorted output"]

node_user -->|"runs"| node_console
node_source -->|"opens"| node_console
node_console -->|"configures"| node_settings
node_console -->|"configures"| node_comparer
node_console -->|"invokes"| node_sorter
node_sorter -->|"reads"| node_settings
node_sorter -->|"splits into"| node_chunks
node_sorter -->|"sorts runs"| node_run_sort
node_sorter -->|"merges runs"| node_merge
node_sorter -->|"writes runs"| node_temp_files
node_run_sort -->|"compares with"| node_comparer
node_merge -->|"compares with"| node_comparer
node_merge -->|"tracks rows"| node_row_cursor
node_sorter -->|"writes result"| node_output

click node_console "https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/Program.cs"
click node_settings "https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorterOptions.cs"
click node_sorter "https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorter.cs"
click node_chunks "https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorter.cs"
click node_run_sort "https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorter.cs"
click node_merge "https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorter.cs"
click node_row_cursor "https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/Row.cs"
click node_temp_files "https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorter.cs"
click node_comparer "https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ColumnSorter.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_console toneBlue
class node_settings,node_sorter,node_chunks,node_run_sort,node_merge,node_row_cursor,node_temp_files toneAmber
class node_comparer toneMint
class node_user,node_source,node_output toneIndigo
```

## Components

### Application entry

- [Console runner](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/Program.cs): `src/SortTestFile/Program.cs`

### External sorting

- [Sort options](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorterOptions.cs): `src/SortTestFile/ExternalMergeSorterOptions.cs`
- [Merge sorter](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorter.cs): `src/SortTestFile/ExternalMergeSorter.cs`
- [Chunk splitting](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorter.cs): `src/SortTestFile/ExternalMergeSorter.cs`
- [Run sorting](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorter.cs): `src/SortTestFile/ExternalMergeSorter.cs`
- [Run merging](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorter.cs): `src/SortTestFile/ExternalMergeSorter.cs`
- [Merge row cursor](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/Row.cs): `src/SortTestFile/Row.cs`
- [Temporary runs](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ExternalMergeSorter.cs): `src/SortTestFile/ExternalMergeSorter.cs`

### Ordering rules

- [Column comparer](https://github.com/rx9agh/sorttestfile/blob/main/src/SortTestFile/ColumnSorter.cs): `src/SortTestFile/ColumnSorter.cs`

### Other components

- **Operator**
- **Input file**
- **Sorted output**

## Connections

- Operator → Console runner: runs (evidence: `src/SortTestFile/Program.cs`)
- Input file → Console runner: opens (evidence: `src/SortTestFile/Program.cs`)
- Console runner → Sort options: configures (evidence: `src/SortTestFile/Program.cs`)
- Console runner → Column comparer: configures (evidence: `src/SortTestFile/Program.cs`)
- Console runner → Merge sorter: invokes (evidence: `src/SortTestFile/Program.cs`)
- Merge sorter → Sort options: reads (evidence: `src/SortTestFile/ExternalMergeSorter.cs`)
- Merge sorter → Chunk splitting: splits into (evidence: `src/SortTestFile/ExternalMergeSorter.cs`)
- Merge sorter → Run sorting: sorts runs (evidence: `src/SortTestFile/ExternalMergeSorter.cs`)
- Merge sorter → Run merging: merges runs (evidence: `src/SortTestFile/ExternalMergeSorter.cs`)
- Merge sorter → Temporary runs: writes runs (evidence: `src/SortTestFile/ExternalMergeSorter.cs`)
- Run sorting → Column comparer: compares with (evidence: `src/SortTestFile/ExternalMergeSorter.cs`)
- Run merging → Column comparer: compares with (evidence: `src/SortTestFile/ExternalMergeSorter.cs`)
- Run merging → Merge row cursor: tracks rows (evidence: `src/SortTestFile/ExternalMergeSorter.cs`)
- Merge sorter → Sorted output: writes result
