Jump to content
UBot Underground

Recommended Posts

I have a table with two columns.  I want to take the table and reverse the entire thing.

 

Example:

 

This original table:

-------------------

|  Dog  |     1    |

-------------------

|   Cat  |     2    |

-------------------

|  Bird  |      4   |

-------------------

|  Fish  |     8   |

-------------------

 

Becomes:

-------------------

|  Fish  |     8   |

-------------------

|  Bird  |      4   |

-------------------

|   Cat  |     2    |

-------------------

|  Dog  |     1    |

-------------------

 

How do I do that?

I tried this which worked but I want it to be in Decending order with Column 1 as the index, not ascending.

plugin command("TableCommands.dll""sort table"&positiveTable, 1)

 

Edited by katelynnm
Link to post
Share on other sites

There is probably a better way to do it but this works:

clear list(%Items)
clear list(%Items2)
clear table(&Table)
clear table(&Temp_Table)
add list to list(%Items, $list from text("Item1
Item2
Item3
Item4", "
"), "Delete", "Global")
add list to list(%Items2, $list from text("Item1
Item2
Item3
Item4", "
"), "Delete", "Global")
add list to table as column(&Table, 0, 0, %Items)
add list to table as column(&Table, 0, 1, %Items2)
divider
set(#Row_Dec, $subtract($table total rows(&Table), 1), "Global")
set(#Row, 0, "Global")
loop($table total rows(&Table)) {
    set table cell(&New_Table, #Row_Dec, 0, $table cell(&Table, #Row, 0))
    set table cell(&New_Table, #Row_Dec, 1, $table cell(&Table, #Row, 1))
    decrement(#Row_Dec)
    increment(#Row)
}

Carl 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...