You need to use an intermediate array or seq to store the ordered keys.

For example: 
[https://github.com/mratsim/glyph/blob/cce4c8dc4af554242513b80283849a2bd0bb6b8f/glyph/snes/private/macros_opcodes.nim#L111](https://github.com/mratsim/glyph/blob/cce4c8dc4af554242513b80283849a2bd0bb6b8f/glyph/snes/private/macros_opcodes.nim#L111)
    
    
    type
      OpcParams* = tuple[name: string, cycles: int, ecc: NimNode, addr_mode: 
NimNode, impl: NimNode]
      OpcTable* = OrderedTable[int, OpcParams]
    
    var opcTable = initOrderedTable[int, OpcParams]()
    ...
    opcTable.sort(proc(x, y: tuple[key: int, val: OpcParams]):int = cmp(x.key, 
y.key))
    
    
    Run

Note: an OrderedTable is a table that remembers order of insertion, it's not a 
SortedTable. sort is only implemented on OrderedTable and there is no 
SortedTable. 

Reply via email to