History
Current version
3/8/2026, 10:06:41 PM
Imported from wiki
by tmascroft · 3/8/2026, 9:32:04 PM
Imported from wiki
by tmascroft · 3/8/2026, 9:32:04 PM
Logic Sorter
## Logic Sorter
:::infobox
| Property | Value |
|----------|-------|
| Prefab Hash | 873418029 |
| Prefab Name | StructureLogicSorter |
| Power Usage | 5W |
| Placed With | [Kit (Sorter)](/wiki/kit-sorter) |
| Placed On | Small Grid |

:::
### Deconstruction Steps
| Step | Tool | Recovered Item |
|---|---|---|
| 1 | [Hand Drill](/wiki/hand-drill) | [Kit (Sorter)](/wiki/kit-sorter) |
*Not to be confused with Sorter.*
## Description
> *"Contains an Internal Memory which is assessed to check whether something should be sorted. When an item is in the Import slot Slot, the stack is checked and if result is true the thing is moved to the Export2 slot slot, otherwise it is moved to the Export slot slot. The Mode is used in how the stack is assessed, by default the mode is ALL, so every instruction in the stack would need to return true."*
> — Stationpedia
Logic sorter is similar in almost every way to the previous sorter but has a internal memory that can be configured with logic and bit shifting to sort items passing through. When an item enters the import slot, it is checked against the filters in memory. If the Mode is 0(All) then every filter must return true for the item to be sent to the export 2 slot. If the mode is 1(Any) then as long as one of the filters returns true, the item matches and will be sent to the export 2 slot.
## Filter Instructions
Check the in game Stationpedia [F1 on your keyboard] for formatting and instruction sizes to determine how to populate the memory. Be warned that the stationpedia fails to document the endianness (bit 0 is the least significant bit). While the stationpedia does document that the Logic Sorter has 256 bytes of memory, it is addressed as 32 x 8-byte (64-bit) numbers.
If you wish your sorter to send [Steel Ingot](/wiki/steel-ingot)s to the second output you should place the value 0xd8f8af8d_01 ( = 931885190401 decimal ) into memory 0. More complicated programs will have to consider whether they want to use Mode 0 (match All), Mode 1 (match Any), or Mode 2 (match None).
It is more readable to calculate the instructions using [IC10](/wiki/ic10) like this:
```
alias sorter d0
define steel HASH("ItemSteelIngot")
s sorter Mode 1 # Any
clr sorter # erase any stale instructions in RAM
sll r0 steel 8
or r0 r0 SorterInstruction.FilterPrefabHashEquals
put sorter 0 r0
```
| Sorter Instruction | OP Code | Description |
|---|---|---|
| FilterPrefabHashEquals | 1 | Compares Hash of item in import slot to the set hash and returns true if equal. |
| FilterPrefabHashNotEquals | 2 | Compares Hash of item in import slot to the set hash and returns true if not equal. |
| FilterSortingClassCompare | 3 | Compares the sorting class of an object in input slot. Example would be all ores. |
| FilterSlotTypeCompare | 4 | Compares the item type of an object in the input slot. See slot type table below for item comparisons. |
| FilterQuantityCompare | 5 | Compares the stack size of the items in the import slot. |
| LimitNextExecutionByCount | 6 | Ensures the next executable instruction will only return true a specified number of times. Each time it returns true, it decrements by one. |
| Conditional Operation (CONDOP) | Value | Pre-shifted |
|---|---|---|
| Equals | 0 | 0 |
| Greater | 1 | 256 |
| Less | 2 | 512 |
| NotEquals | 3 | 768 |
<pre>
MSB LSB
6666555555555544444444443333333333222222222211111111110000000000
3210987654321098765432109876543210987654321098765432109876543210
FilterPrefabHashEquals
1. ( PREFAB_HASH)( 1)
FilterPrefabHashNotEquals
1. ( PREFAB_HASH)( 2)
FilterSortingClassCompare
1. ( SORTING_CLASS)(CONDOP)( 3)
FilterSlotTypeCompare
1. ( SLOT_TYPE)(CONDOP)( 4)
FilterQuantityCompare
1. ( QUANTITY)(CONDOP)( 5)
LimitNextExecutionByCount
1. ( COUNT)( 6)
</pre>
## Data Network
| Parameter | Type | Access | Description |
|---|---|---|---|
| Power | Boolean | Read | Can be read to return if the Logic Sorter is correctly powered or not, set via the power system, return 1 if powered and 0 if not |
| Mode | Integer | Read/Write | The mode of the Logic Sorter. |
| Error | Boolean | Read | 1 if device is in error state, otherwise 0 |
| Lock | Boolean | Read/Write | Disable manual operation of the Logic Sorter. |
| On | Boolean | Read/Write | The current state of the Logic Sorter. |
| RequiredPower | Integer | Read | Idle operating power quantity, does not necessarily include extra demand power |
| ClearMemory | Integer | Read/Write | r=0 |
| ExportCount | Integer | Read | How many items exported since last ClearMemory |
| ImportCount | Integer | Read | How many items imported since last ClearMemory |
| PrefabHash | Integer | Read | The hash of the structure |
| ReferenceId | Integer | Read | Unique Reference Identifier for this object |
| NameHash | Integer | Read | Provides the hash value for the name of the object as a 32 bit integer. |
### Data Slots
These are all parameters, that can be read with a [Slots Reader](/wiki/kit-logic-io#slots-reader). The outputs are listed in the order a Slots Reader's "VAR" setting cycles through them.
| Number || Name | Description |
|---|---|
| 0 | Import |
| 1 | Export (reject) |
| 2 | Export (accept) |
| 3 | Data Disk |
| Name | Data Type | Description |
|---|---|---|
| MaxQuantity | Integer | Returns maximum stacksize. |
| Damage | Integer | Item durability in percent. |
| Class | Integer | Item class ID for slot type comparison. |
| SortingClass | Integer | Class group of items. |
| Quantity | Integer | Size of item stack. |
| PrefabHash | Integer | Returns [ItemHash](/wiki/itemhash) of item in slot. |
| Occupied | Boolean | Returns whether the slot occupied. (0 for no, 1 for yes). |
| OccupantHash | Integer | Returns [ItemHash](/wiki/itemhash) of item in slot. |
## Item Slot Classes / Types
Reading the *class* attribute of the input slot will give one of the following values:
Note that you can use <pre style="display: inline">SlotClass.<Item></pre> directly in IC code instead of the numeric value
- NOTE The classes listed in this section are FilterSlotTypeCompare and NOT sorting class. eg: SortingClass.Ores vs SlotClass.Ore
| + Item values and descriptions | Item | Value | Description | Item | Value | Description | Item | Value | Description |
|---|---|---|---|---|---|---|---|---|---|
| None | 0 | | Helmet | 1 | | Suit | 2 | | |
| Back | 3 | | GasFilter | 4 | | GasCanister | 5 | | |
| Motherboard | 6 | | Circuitboard | 7 | | DataDisk | 8 | | |
| Organ | 9 | | Ore | 10 | Includes reagent mixes from recycler and ices | Plant | 11 | | |
| Uniform | 12 | | Entity | 13 | | Battery | 14 | | |
| Egg | 15 | | Belt | 16 | | Tool | 17 | | |
| Appliance | 18 | | Ingot | 19 | | Torpedo | 20 | | |
| Cartridge | 21 | | AccessCard | 22 | | Magazine | 23 | | |
| Circuit | 24 | | Bottle | 25 | | ProgrammableChip | 26 | | |
| Glasses | 27 | | CreditCard | 28 | | DirtCanister | 29 | | |
| SensorProcessingUnit | 30 | | LiquidCanister | 31 | | LiquidBottle | 32 | | |
| Wreckage | 33 | | SoundCartridge | 34 | | DrillHead | 35 | | |
| ScanningHead | 36 | | Flare | 37 | | Blocked | 38 | | |
| SuitMod | 39 | | Crate | 40 | | Portables | 41 | | |