Line 4: |
Line 4: |
| local Ship = require('Module:Ship') | | local Ship = require('Module:Ship') |
| local Formatting = require('Module:Formatting') | | local Formatting = require('Module:Formatting') |
| + | local SortId = require('Module:DropList/Sort') |
| | | |
| -- * Rarity definitions. | | -- * Rarity definitions. |
Line 192: |
Line 193: |
| ship = ship, | | ship = ship, |
| rare = rare, | | rare = rare, |
| + | ignored = ignored, |
| regular = regular, | | regular = regular, |
| ship_color = rarity_colors[ignored][rare], | | ship_color = rarity_colors[ignored][rare], |
| type = Formatting:format_ship_code(ship_table._type) or '?', | | type = Formatting:format_ship_code(ship_table._type) or '?', |
| + | type_id = ship_table._type, |
| + | sort_id = SortId[ship_table._api_id], |
| nodes = {}, | | nodes = {}, |
| }) | | }) |
Line 288: |
Line 292: |
| }) | | }) |
| end | | end |
| + | |
| + | -- true when the first is less than the second (so that not comp(a[i+1],a[i]) will be true after the sort). If comp is not given, then the standard Lua operator < is used instead. |
| + | |
| + | table.sort(tbl.rows, function(a, b) |
| + | if a.type_id < b.type_id then |
| + | return true |
| + | elseif a.type_id == b.type_id then |
| + | return a.sort_id < b.sort_id |
| + | else |
| + | return false |
| + | end |
| + | end) |
| | | |
− | -- rows
| |
| for _, row in pairs(tbl.rows) do | | for _, row in pairs(tbl.rows) do |
− | -- TODO: Sort by type/name
| |
| if row.rare then | | if row.rare then |
| add_row(row) | | add_row(row) |
Line 297: |
Line 311: |
| end | | end |
| for key, row in pairs(tbl.rows) do | | for key, row in pairs(tbl.rows) do |
− | -- TODO: Sort by type/name | + | if not row.rare and not row.ignored then |
− | if not row.rare then | + | add_row(row) |
| + | end |
| + | end |
| + | for key, row in pairs(tbl.rows) do |
| + | if row.ignored then |
| add_row(row) | | add_row(row) |
| end | | end |