Walter1 8 Posted June 26, 2013 Report Share Posted June 26, 2013 Hey botters! Here is a question i have been breaking my head over since the last couple of days. As the title already stated, how can i reverse a list? Say list a contains:date 3date 2date 1 I want to get another list with:date 1date 2date 3 Been looking all over the place but since the search function here kinda sucks and google didnt came up with a proper answer i ask this here on the forum. Anyone? Quote Link to post Share on other sites
UBotDev 276 Posted June 27, 2013 Report Share Posted June 27, 2013 I think this is the most elegant way (you only need one variable, which is a pointer to list position/integer): clear list(%LIST) add list to list(%LIST, $list from text("date 3 date 2 date 1", $new line), "Don\'t Delete", "Global") set(#LIST ROW, $subtract($list total(%LIST), 1), "Global") loop($list total(%LIST)) { add item to list(%LIST, $list item(%LIST, #LIST ROW), "Don\'t Delete", "Global") remove from list(%LIST, #LIST ROW) decrement(#LIST ROW) } Quote Link to post Share on other sites
danoctav 7 Posted June 27, 2013 Report Share Posted June 27, 2013 The easiest method : add list to list(%reversed_list, $sort list(%mylist, "Ascending"), "Delete", "Global") where %mylist is your list with descending items.... but can be done in many,many ways.... Quote Link to post Share on other sites
UBotDev 276 Posted June 27, 2013 Report Share Posted June 27, 2013 The easiest method : add list to list(%reversed_list, $sort list(%mylist, "Ascending"), "Delete", "Global") where %mylist is your list with descending items.... but can be done in many,many ways....This won't reverse the list, it will sort it. Quote Link to post Share on other sites
Walter1 8 Posted June 27, 2013 Author Report Share Posted June 27, 2013 Thanks all you guys for your ideas, awesome!For some stupid reason it didnt work for me or just partial, with a few lines messed up in the reversed lists.But i came up with a solution, done with the input from you guys set(#STATUS, $text from list($sort list(%STATUS, "Descending"), $new line), "Global") This did the trick for me... Thanks guys for all your input! Quote Link to post Share on other sites
danoctav 7 Posted June 27, 2013 Report Share Posted June 27, 2013 This won't reverse the list, it will sort it.Yes,and sorting will reverse that list (particular case for the list given ) Quote Link to post Share on other sites
UBotDev 276 Posted June 28, 2013 Report Share Posted June 28, 2013 Yes,and sorting will reverse that list (particular case for the list given )Ok, it will reverse this specific list, but I thought Walter is trying to use real dates inside list...if dates aren't sorted at start and aren't sortable format it won't work. Quote Link to post Share on other sites
jainteq 0 Posted July 2, 2013 Report Share Posted July 2, 2013 Excellent and helpful post… I am so glad to left comment on this. Quote Link to post Share on other sites
dankass 52 Posted August 21, 2013 Report Share Posted August 21, 2013 Almost weird that there is no command for this, and nobody has added it to a plugin or anything yet. 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.