luis 0 Posted April 19, 2012 Report Share Posted April 19, 2012 Hi all, I have a list of numbers that I need to sort. When I use "$sort list" all the numbers are sorted by the first digit but not the whole number. Any idea how can I do that. Example of list: 100011001001 What a need: 110010001100 Thanks! Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted April 19, 2012 Report Share Posted April 19, 2012 set(#temp, "100 5000 1100 1000 10", "Global") clear list(%test) add list to list(%test, $list from text(#temp, $new line), "Delete", "Global") clear list(%clean) add list to list(%clean, $sort list(%test, "Ascending"), "Delete", "Global") clear list(%test) seems to be working.http://screencast.com/t/PIVU4alT63Sx Quote Link to post Share on other sites
luis 0 Posted April 19, 2012 Author Report Share Posted April 19, 2012 Thanks!! I see your example working. But I get things like: 149169917517902892899299349 Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted April 19, 2012 Report Share Posted April 19, 2012 i see what your saying now. very interesting. it doesn't as you said seem to be going past the 1st character, number in the line. Quote Link to post Share on other sites
luis 0 Posted April 19, 2012 Author Report Share Posted April 19, 2012 Yes that's the issue, any idea??? Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted April 19, 2012 Report Share Posted April 19, 2012 nothing you or i can fix using nodes in ubot, im trying to find an alternative way to do it now with java but coming up blank so far. Quote Link to post Share on other sites
Anonym 53 Posted April 19, 2012 Report Share Posted April 19, 2012 It's probably because UBot works with strings, not numbers. There is probably a type casting of strings every time Ubot does any mathematical stuff with numbers. You could probably try to add a proper amount of zeros in the beginning of each number, except for the biggest number(s). Ok, it's not very beautiful, but it will probably work. Quote Link to post Share on other sites
luis 0 Posted April 19, 2012 Author Report Share Posted April 19, 2012 Here is the solution, but I don´t understand how to use it on uBot. http://www.w3schools.com/jsref/jsref_sort.asp Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted April 19, 2012 Report Share Posted April 19, 2012 seen it and tried it doesnt seem to work.. Quote Link to post Share on other sites
k1lv9h 76 Posted April 20, 2012 Report Share Posted April 20, 2012 Hi, If you were to save the list to a text file. You could then run a Ubot shell cmd.exe /C sort input-file.txt /O sorted-file.txtWindow Command Prompt sort /? for help. Then read the sorted text file back in to a list variable for further processing. Kevin Quote Link to post Share on other sites
JohnB 255 Posted April 21, 2012 Report Share Posted April 21, 2012 Did you try adding a decimal point to the end of each number? John Quote Link to post Share on other sites
a2mateit 395 Posted June 20, 2012 Report Share Posted June 20, 2012 Anyone have a fix for this yet? I am running into the same problem... Quote Link to post Share on other sites
a2mateit 395 Posted June 20, 2012 Report Share Posted June 20, 2012 Tried adding a decimal, but it's not working... Quote Link to post Share on other sites
a2mateit 395 Posted June 20, 2012 Report Share Posted June 20, 2012 Hey Willy, Thanks for trying to help me out. I will try this in a sec, but do you know if it will keep the order. For example my list is 1289,website.com - 1238,website.com - so on and so forth. Will this keep the right websites associated with the right numbers? Thanks,Justin Quote Link to post Share on other sites
a2mateit 395 Posted June 20, 2012 Report Share Posted June 20, 2012 Hey Willy, Not working for numbers outside of their comma... For instance:1,000,0001,32110,000,321100,01120,03231,209,29010040,021500,930 It will not sort this list correctly. Unless I am missing something Quote Link to post Share on other sites
a2mateit 395 Posted June 20, 2012 Report Share Posted June 20, 2012 That will work for just the numbers. But, after my numbers I have domains. And some of them are short and the other ones are long. So length does not work in my case. Ex:1,000,000,acme.com1,321,acmewebsite.com10,000,321,a.com100,011,xyz.com20,032,acme.com31,209,290,acme.com100,acmesbiggestwebsite.com40,021,acmesotherbiggestwebsite.com500,930,ubot.com Gives me the following when using length:100,011,xyz.com20,032,acme.com10,000,321,a.com500,930,ubot.com1,000,000,acme.com31,209,290,acme.com1,321,acmewebsite.com100,acmesbiggestwebsite.com40,021,acmesotherbiggestwebsite.com So this is quite a dilema. Doesn't seem to be a fix for this... Justin Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted June 20, 2012 Report Share Posted June 20, 2012 I think this is the exact issue at hand and shows means how it can be fixed by means of a update to ubot functionality. http://blogs.technet.com/b/heyscriptingguy/archive/2008/02/12/how-can-i-use-windows-powershell-to-sort-a-csv-file.aspx 2 Quote Link to post Share on other sites
thejake 11 Posted June 21, 2012 Report Share Posted June 21, 2012 This works: var outs = Array(); outs.length = 999999999; var source ="31209290,acme.com\n100,acmesbiggestwebsite.com\n40021,acmesotherbiggestwebsite.com"; var list = source.split("\n"); for (i in list) { parts = list[i].split(","); outs[parts[0]] = list[i]; } var sortedlist = ""; for (j in outs) {if (outs[j]) sortedlist = sortedlist +outs[j] +"\n";} return sortedlist; Quote Link to post Share on other sites
a2mateit 395 Posted June 21, 2012 Report Share Posted June 21, 2012 What exactly you want to do and how this numbers and domains are gathered? You can accomplish things in different ways with ubot. For example you could have the numbers sorted first and then replace the number for number with the domain at the end.I am scraping a large lists of sites to get their alexa rank. It outputs the file as a semi colon seperated .txt file i.e. - Alexa Rank;Website. I would like to be able to save it with the highest rated ranking on top and go on from there. I believe I can achieve this in excel, but that kind of defeats the whole purpose of "automating" this task. Thanks for all the suggestions so far... Would be nice to get this working. Quote Link to post Share on other sites
a2mateit 395 Posted June 21, 2012 Report Share Posted June 21, 2012 This works: var outs = Array(); outs.length = 999999999; var source ="31209290,acme.com\n100,acmesbiggestwebsite.com\n40021,acmesotherbiggestwebsite.com"; var list = source.split("\n"); for (i in list) { parts = list[i].split(","); outs[parts[0]] = list[i]; } var sortedlist = ""; for (j in outs) {if (outs[j]) sortedlist = sortedlist +outs[j] +"\n";} return sortedlist; How exactly do I use this? Run it as Javascript? How do I use it with a list? How do I output it back to a list? Thanks,Justin Quote Link to post Share on other sites
thejake 11 Posted June 21, 2012 Report Share Posted June 21, 2012 How exactly do I use this? Run it as Javascript? How do I use it with a list? How do I output it back to a list? Thanks,Justin I'd do it more or less like: set(#input, "132,test1\n", "Global") set(#input, "{#input}8931,test2\n", "Global") set(#input, "{#input}1322221,test3\n", "Global") set(#input, "{#input}5499,test4\n", "Global") set(#sorted, $eval(" var outs = Array(); outs.length = 999999999; var source =\"{#input}\"; var list = source.split(\"\\n\"); for (i in list) \{ parts = list[i].split(\",\"); outs[parts[0]] = list[i]; \} var sortedlist = \"\"; for (j in outs) \{if (outs[j]) sortedlist = sortedlist +outs[j] +\"\\n\";\} sortedlist; "), "Global") alert(#sorted) Of course the set for #input would be in your loop and probably be more like set(#input, "{#input}{#rank},{#domain}\n", "Global") and it's probably a better idea to save #sorted instead of alert but that's probably the easiest way to skin the cat. 2 Quote Link to post Share on other sites
a2mateit 395 Posted June 21, 2012 Report Share Posted June 21, 2012 I'd do it more or less like: set(#input, "132,test1\n", "Global") set(#input, "{#input}8931,test2\n", "Global") set(#input, "{#input}1322221,test3\n", "Global") set(#input, "{#input}5499,test4\n", "Global") set(#sorted, $eval(" var outs = Array(); outs.length = 999999999; var source =\"{#input}\"; var list = source.split(\"\\n\"); for (i in list) \{ parts = list[i].split(\",\"); outs[parts[0]] = list[i]; \} var sortedlist = \"\"; for (j in outs) \{if (outs[j]) sortedlist = sortedlist +outs[j] +\"\\n\";\} sortedlist; "), "Global") alert(#sorted) Of course the set for #input would be in your loop and probably be more like set(#input, "{#input}{#rank},{#domain}\n", "Global") and it's probably a better idea to save #sorted instead of alert but that's probably the easiest way to skin the cat. I'm guessing this is regex?... Haven't learned that yet. Gonna have to sleep on that one. I'm sure it will click in the morning. Still open for easier solutions though Still looking for easier ways to skin the cat. Keep in mind I am trying to sort the list After it is created, with a semi colon delimiter. I guess I just need to know if this is possible within Ubot, or maybe thejake could possibly dumb it down for me? Feel free to PM me or share it here. Justin Quote Link to post Share on other sites
Legend 181 Posted June 21, 2012 Report Share Posted June 21, 2012 that's some serious eval... very nice! http://www.ubotstudio.com/forum/public/style_emoticons/default/blink.gif Quote Link to post Share on other sites
a2mateit 395 Posted June 21, 2012 Report Share Posted June 21, 2012 I think this is the exact issue at hand and shows means how it can be fixed by means of a update to ubot functionality. http://blogs.technet.com/b/heyscriptingguy/archive/2008/02/12/how-can-i-use-windows-powershell-to-sort-a-csv-file.aspx+1 Quote Link to post Share on other sites
firionicable 0 Posted June 22, 2012 Report Share Posted June 22, 2012 I will second that notion!! 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.