Guest slimshacaca Posted October 5, 2004 Share Posted October 5, 2004 I am currently using AutoIt v3.0.102... And i need help or guidence on how i can arrange an arry of numbers from smallest to largest while the end result is still an arry... EX: 15|14|22|02|20|01|33 I need help taking that to: 01|02|14|15|20|22|33 Please help :"> Link to comment Share on other sites More sharing options...
emmanuel Posted October 5, 2004 Share Posted October 5, 2004 I am currently using AutoIt v3.0.102...And i need help or guidence on how i can arrange an arry of numbers from smallest to largest while the end result is still an arry... EX: 15|14|22|02|20|01|33I need help taking that to: 01|02|14|15|20|22|33Please help :"><{POST_SNAPBACK}>you may want to check out a few of the results I pulled up on a search for "bubble sort":http://www.autoitscript.com/forum/index.ph...findpost&p=5930 "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
scriptkitty Posted October 6, 2004 Share Posted October 6, 2004 (edited) Bubblesort is the best, but here is a slow way to do it with arrays. $array1=StringSplit("15|14|22|02|20|01|33","|") $array2=$array1 Dim $arrayout[$array1[0]+1] $arrayout[0]=$array1[0] $x=1 for $h=1 to $array2[0] for $i=1 to $array2[0] if number($array2[$x])>number($array2[$i]) then $x=$i next $array2[$x]=999999999 $arrayout[$h]=$array1[$x] next ; array display $x="" for $i=1 to $arrayout[0] $x=$x & "|" & $arrayout[$i] next $x=StringTrimLeft($x,1) msgbox(1,"list",$x) Quick and dirty, and I should redim and stuff, but you can see the output. For use I would go bubblesort. edit.. just FYI since I wrote over each item in the output array, you could replace: Dim $arrayout[$array1[0]+1] $arrayout[0]=$array1[0] with Dim $arrayout=$array1 This is more of a teaching script than anything, although it works. Edited October 6, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Guest slimshacaca Posted October 7, 2004 Share Posted October 7, 2004 Thank you both for your assistance, answered my question perfectly and enlightened me in a new way to look at the array system in AutoIt. Thanks muches Slim Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now