brodie28 Posted August 26, 2006 Share Posted August 26, 2006 I am making a script which is supposed to get the highest 50 numbers of the data I put in. I have worked out how to populate the array... My problem is how I can go about getting the highest 50 in order... DO I populate it first or sort them as I go... How should I sort them? Link to comment Share on other sites More sharing options...
Developers Jos Posted August 26, 2006 Developers Share Posted August 26, 2006 (edited) I am making a script which is supposed to get the highest 50 numbers of the data I put in.I have worked out how to populate the array... My problem is how I can go about getting the highest 50 in order... DO I populate it first or sort them as I go... How should I sort them?_ArraySort() can sort the array Descending after which you can list the first 50 entries.Make sure you save the values in numeric format in stead of alphanumeric by ysing the Number() function. Edited August 26, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
brodie28 Posted August 26, 2006 Author Share Posted August 26, 2006 The problem I have is that there are four arrays. I have Names[50] ids[50] numbers[50] They are all tied to each other so if I change the order of one array it will mess up the others. Link to comment Share on other sites More sharing options...
Developers Jos Posted August 26, 2006 Developers Share Posted August 26, 2006 The problem I have is that there are four arrays. I have Names[50] ids[50] numbers[50] They are all tied to each other so if I change the order of one array it will mess up the others.The easiest way is to make it one Array like $Records[50][3]... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
brodie28 Posted August 26, 2006 Author Share Posted August 26, 2006 (edited) Yeah it seems to be going a bit better now. Thanks. Edited August 26, 2006 by brodie28 Link to comment Share on other sites More sharing options...
brodie28 Posted August 26, 2006 Author Share Posted August 26, 2006 How do I use functions like _ArrayMin with Multidimensional arrays? I have the number saved at $array[1][0][0][0], $array[2][0][0][0] etc. How would I use That function to find the smallest number? Link to comment Share on other sites More sharing options...
Developers Jos Posted August 26, 2006 Developers Share Posted August 26, 2006 How do I use functions like _ArrayMin with Multidimensional arrays? I have the number saved at $array[1][0][0][0], $array[2][0][0][0] etc. How would I use That function to find the smallest number?Think your are approaching it the wrong way. Your Array has to be defined as: Dim $Array[50][4] Then the 4 values for the first record are set in this way: $Array[0][0] = Number("Field 1 value") $Array[0][1] = "Field 2 value" $Array[0][2] = "Field 3 value" $Array[0][3] = "Field 4 value" Fill all 50 records and then sort the Array : Here is an example program to get you started: #include<array.au3> Dim $Array[50][4] ;Then the 4 values for the first record are set in this way: For $x = 0 to 49 $Array[$x][0] = Random(1,100,1) $Array[$x][1] = "Record:" & $x $Array[$x][2] = "Field 3 value" $Array[$x][3] = "Field 4 value" Next ;Fill all 50 records and then sort the Array : _ArraySort($Array,1,0,0,4,0) ; Now list them For $x = 0 to 49 Msgbox (0," record:" & $x, " Field 1:" & $Array[$x][0] & @LF & _ $Array[$x][1] & @LF & _ $Array[$x][2] & @LF & _ $Array[$x][3] & @LF) Next SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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