📦 Sorting¶
Sorting contracts for inventory slot ordering.
This folder defines the public abstraction used for inventory sorting. It describes how a sorter receives slot data and sort rules, but it does not implement sorting itself.
🎯 Purpose¶
Provide a replaceable strategy seam for ordering inventory slot data.
🧩 What Lives Here¶
IInventorySorter¶
Strategy contract for sorting inventory entries in place.
Receives:
- a list of
(ItemStack stack, int originalIndex)tuples - an
InventorySortSpec
Reorders that list according to its implementation.
InventorySortKey¶
Supported built-in comparison keys:
- Name
- Rarity
- Category
- Quantity
InventorySortSpec¶
Public sort description.
Includes:
- primary
- ascending
- optional secondary key via
then - thenAscending
- emptySlotsLast
Also includes a convenience factory such as ByNameAsc().
⚠️ Important Notes¶
- This folder defines the sorting contract only
- It does not implement comparison logic
- It does not mutate containers directly
🧠 Usage Guidance¶
Strategy seam¶
IInventorySorter allows projects to replace ordering behaviour when they control the service instance.
Stable ordering support¶
The sorter receives original slot indices.
Implementations may use this to preserve deterministic ordering.
Sort description vs execution¶
InventorySortSpec describes ordering rules only.
Creating a spec does not perform a sort. A service or caller must apply it.
🚫 Not for Production Use¶
This folder does not:
- Define a default sort algorithm
- Guarantee locale-aware or natural sorting
- Guarantee stable ordering
- Perform container mutation
These behaviours belong to runtime implementations.