Line 21: |
Line 21: |
| function Iterator.equipmentById(context, n) | | function Iterator.equipmentById(context, n) |
| local fromKey = "from" .. (n and tostring(n) or "") | | local fromKey = "from" .. (n and tostring(n) or "") |
| + | local from = context and context[fromKey] and tonumber(context[fromKey]) or 1 |
| local toKey = "to" .. (n and tostring(n) or "") | | local toKey = "to" .. (n and tostring(n) or "") |
− | local from = context and context[fromKey] and tonumber(context[fromKey]) or 1
| |
| local to = context and context[toKey] and tonumber(context[toKey]) or 500 | | local to = context and context[toKey] and tonumber(context[toKey]) or 500 |
| + | local sortKey = "sort" .. (n and tostring(n) or "") |
| + | local sort = context and context[sortKey] |
| local collection = require('Module:Collection/Equipment') | | local collection = require('Module:Collection/Equipment') |
| + | if sort then |
| + | collection = table.sort(collection, function(a, b) return a[sort] < b[sort] end) |
| + | end |
| local i = 1 | | local i = 1 |
| local current | | local current |
Line 54: |
Line 59: |
| local type = context and context[typeKey] and tonumber(context[typeKey]) | | local type = context and context[typeKey] and tonumber(context[typeKey]) |
| local sortKey = "sort" .. (n and tostring(n) or "") | | local sortKey = "sort" .. (n and tostring(n) or "") |
− | local sort = context and context[sortKey] and tonumber(context[sortKey]) | + | local sort = context and context[sortKey] |
| local collection = require('Module:Collection/Equipment') | | local collection = require('Module:Collection/Equipment') |
| if sort then | | if sort then |