ibotubot 3 Posted November 2, 2017 Report Share Posted November 2, 2017 Hi all, I want to sort a table which has a header, to be first sorted by say column A then column B, as one would do in Excel. Could not think of another solution given that for example putting each column (a and into a list and then sorting would obviously not be accurate Quote Link to post Share on other sites
ibotubot 3 Posted November 2, 2017 Author Report Share Posted November 2, 2017 Can be closed Solution for me : use sqlite plugin and then easily sort in there to get around the text sorting limitation. Quote Link to post Share on other sites
HelloInsomnia 1103 Posted November 3, 2017 Report Share Posted November 3, 2017 I'll leave it open and leave a solution as well for others who don't know how to use Sqlite, the Table Commands plugin comes with Ubot: clear table(&data) set table cell(&data,0,0,"b") set table cell(&data,0,1,1) set table cell(&data,1,0,"a") set table cell(&data,1,1,5) plugin command("TableCommands.dll", "sort table", &data, 0) alert(&data) plugin command("TableCommands.dll", "sort table", &data, 1) alert(&data) 2 Quote Link to post Share on other sites
ibotubot 3 Posted November 3, 2017 Author Report Share Posted November 3, 2017 I should have been more precise (screenshot did not work.) : I wanted to sort by Column A THEN Column B, so in that order. Imagine an Example of Say TV Series, You have Season 1, Season 2....but then each season has Episode 1 , 2,3.... So the output should be Season 1 , 1Season 1 , 2Season 2, 1Season 2 , 2 But as you can see fromt he example below it just sorts column A, then it sorts B isolated now in the same process. Hope that makes more sense now clear table(&data) set table cell(&data,0,0,"Season 1") set table cell(&data,0,1,2) set table cell(&data,1,0,"Season 1") set table cell(&data,1,1,1) set table cell(&data,2,0,"Season 2") set table cell(&data,2,1,2) set table cell(&data,3,0,"Season 2") set table cell(&data,3,1,1) plugin command("TableCommands.dll", "sort table", &data, 0) alert(&data) plugin command("TableCommands.dll", "sort table", &data, 1) alert(&data) I tried working on a solution just using tables and lists, but realized it turned into way too much effort and I will rather just use Ayman's SQLite plugin. The above example is very simple s could likely be solved by adding another sort, But what If I need to sot by A,B,C and then add in descending vs. regular ascending (for letter and numbers)... Quote Link to post Share on other sites
HelloInsomnia 1103 Posted November 3, 2017 Report Share Posted November 3, 2017 You can extract each season into its own table and then sort those tables and add them together but if you already have a solution then that's probably better. But basically it would involve first sorting by season, then using the table search function to find the row index of the start of the next season. Extracting the current season into a table, sort that table and then go to the next. Quote Link to post Share on other sites
ibotubot 3 Posted November 3, 2017 Author Report Share Posted November 3, 2017 I figured it is easier to use sql queries for that , as I tried it earlier with say 3 columns. Also , given that this example was pretty easy, but with 3 columns some could be strings, others numbers that would need to be sorted descending etc... It just seemed to be saving way more time just using sql for this. Appreciate the replies though ! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.