Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-08-24, 09:54 AM   #1
Doctorbeefy
A Defias Bandit
Join Date: Apr 2024
Posts: 1
Sorting table help

I am trying to sort this table by ID but I can't seem to figure it out, is there anyone out there that can assist me? Thank you in advance.

Here is my code:
Lua Code:
  1. function ess(x)
  2.     if not ITEMSCRAPESTATS  then
  3.         ITEMSCRAPESTATS = {}
  4.     end
  5.    ES:SetHyperlink("item:"..x..":0:0:0:0:0:0:0")
  6.    for i=1, ES:NumLines() do
  7.        local text = _G["ESTooltipTextLeft"..i]:GetText()
  8.        if _G["ESTooltipTextLeft2"]:GetText() then
  9.        ITEMSCRAPESTATS[x] = ITEMSCRAPESTATS[x] or {}
  10.        table.insert(ITEMSCRAPESTATS[x], _G["ESTooltipTextLeft"..i]:GetText())
  11.  
  12.        else
  13.        ITEMSCRAPESTATS[x] = ITEMSCRAPESTATS[x] or {}
  14.        table.insert(ITEMSCRAPESTATS[x], "No Stats for Item Number")
  15.        end
  16.    end
  17.     if _G["ESTooltipTextLeft2"]:GetText() then
  18.       print("Scraping Stats for Item Number: "..x)
  19.       else
  20.       print("No Stats for Item Number: "..x)
  21.       end
  22. end

This is what ends up in the table:

Lua Code:
  1. ITEMSCRAPESTATS = {
  2.     [60002] = {
  3.         "Goldroar Signet", -- [1]
  4.         "Binds when picked up", -- [2]
  5.         "Unique-Equipped", -- [3]
  6.         "Finger", -- [4]
  7.         "+1 Strength", -- [5]
  8.         "Item Level 15", -- [6]
  9.         " ", -- [7]
  10.     },
  11.     [60004] = {
  12.         "Divining Rod", -- [1]
  13.         "Binds when picked up", -- [2]
  14.         "Ranged", -- [3]
  15.         "9 - 17 Fire Damage", -- [4]
  16.         "(8.7 damage per second)", -- [5]
  17.         "Requires Level 6", -- [6]
  18.         "Item Level 12", -- [7]
  19.         " ", -- [8]
  20.     },
  21.     [60001] = {
  22.         "Goldroar Band", -- [1]
  23.         "Binds when picked up", -- [2]
  24.         "Unique-Equipped", -- [3]
  25.         "Finger", -- [4]
  26.         "+1 Intellect", -- [5]
  27.         "Item Level 15", -- [6]
  28.         " ", -- [7]
  29.     },
  30.     [60003] = {
  31.         "Waterlogged Dirge", -- [1]
  32.         "Binds when picked up", -- [2]
  33.         "Two-Hand", -- [3]
  34.         "17 - 26 Damage", -- [4]
  35.         "(7.2 damage per second)", -- [5]
  36.         "+1 Strength", -- [6]
  37.         "+1 Stamina", -- [7]
  38.         "Requires Level 6", -- [8]
  39.         "Item Level 10", -- [9]
  40.         " ", -- [10]
  41.     },
  42.     [60000] = {
  43.         "Resilient Poncho", -- [1]
  44.         "Binds when picked up", -- [2]
  45.         "Back", -- [3]
  46.         "20 Armor", -- [4]
  47.         "+1 Spirit", -- [5]
  48.         "Requires Level 6", -- [6]
  49.         "Item Level 26", -- [7]
  50.         " ", -- [8]
  51.     },
  52. }

I would like it to sort like this:

Lua Code:
  1. ITEMSCRAPESTATS = {
  2.     [60000] = {
  3.         "Resilient Poncho", -- [1]
  4.         "Binds when picked up", -- [2]
  5.         "Back", -- [3]
  6.         "20 Armor", -- [4]
  7.         "+1 Spirit", -- [5]
  8.         "Requires Level 6", -- [6]
  9.         "Item Level 26", -- [7]
  10.         " ", -- [8]
  11.     },
  12.     [60001] = {
  13.         "Goldroar Band", -- [1]
  14.         "Binds when picked up", -- [2]
  15.         "Unique-Equipped", -- [3]
  16.         "Finger", -- [4]
  17.         "+1 Intellect", -- [5]
  18.         "Item Level 15", -- [6]
  19.         " ", -- [7]
  20.     }
  21.     [60002] = {
  22.         "Goldroar Signet", -- [1]
  23.         "Binds when picked up", -- [2]
  24.         "Unique-Equipped", -- [3]
  25.         "Finger", -- [4]
  26.         "+1 Strength", -- [5]
  27.         "Item Level 15", -- [6]
  28.         " ", -- [7]
  29.     },
  30.     [60003] = {
  31.         "Waterlogged Dirge", -- [1]
  32.         "Binds when picked up", -- [2]
  33.         "Two-Hand", -- [3]
  34.         "17 - 26 Damage", -- [4]
  35.         "(7.2 damage per second)", -- [5]
  36.         "+1 Strength", -- [6]
  37.         "+1 Stamina", -- [7]
  38.         "Requires Level 6", -- [8]
  39.         "Item Level 10", -- [9]
  40.         " ", -- [10]
  41.     }
  42.     [60004] = {
  43.         "Divining Rod", -- [1]
  44.         "Binds when picked up", -- [2]
  45.         "Ranged", -- [3]
  46.         "9 - 17 Fire Damage", -- [4]
  47.         "(8.7 damage per second)", -- [5]
  48.         "Requires Level 6", -- [6]
  49.         "Item Level 12", -- [7]
  50.         " ", -- [8]
  51.     },
  52. }
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Sorting table help


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off