autoitfan Posted January 28, 2008 Share Posted January 28, 2008 I have an array containing song titles I tried to sort with _ArraySort. One of the titles is 12th Street Rag which appears as 0 (a numeric zero) in the sorted output. Numbers within a title beginning with an alpha character don't appear to cause any problems. I could not find a documented restriction to the effect that alphanumeric array content must begin with an alpha character. When I change the title to "Twelfth Street Rag", _ArraySort generates perfectly sorted output, but control of the titles is not mine, so this is not an acceptable bypass. Is this a bug or just the way it works? And, is there another way to sort an array? Link to comment Share on other sites More sharing options...
GEOSoft Posted January 28, 2008 Share Posted January 28, 2008 (edited) I have an array containing song titlesI tried to sort with _ArraySort. One of thetitles is 12th Street Rag which appearsas 0 (a numeric zero) in the sorted output.Numbers within a title beginning with analpha character don't appear to causeany problems.I could not find a documented restriction tothe effect that alphanumeric array contentmust begin with an alpha character. When I change the title to "Twelfth StreetRag", _ArraySort generates perfectlysorted output, but control of the titlesis not mine, so this is not an acceptablebypass.Is this a bug or just the way it works?And, is there another way to sort anarray?How are you building the array and how are you calling _ArraySort()? You could be starting the sort on the wrong element. It's happened to me more than once. Edited January 28, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
autoitfan Posted January 28, 2008 Author Share Posted January 28, 2008 How are you building the array and how are you calling _ArraySort()? You could be starting the sort on the wrong element. It's happened to me more than once.Thank you for your response. The unsorted song titles arecontained in a simple flat file in the order they were addedto the file. They are simply read into an one dim array, onetitle per element. Keep in mind that the sorted output is correct except for the one title (12th Street Rag) that beginswith a numeric, the sorted output is correct except for thatsingle title which appears as a zero (0), and that simplychanging the "12" to "Twelf" results in sort output that isperfect in every respect.Paul Link to comment Share on other sites More sharing options...
GEOSoft Posted January 29, 2008 Share Posted January 29, 2008 (edited) Thank you for your response. The unsorted song titles are contained in a simple flat file in the order they were added to the file. They are simply read into an one dim array, one title per element. Keep in mind that the sorted output is correct except for the one title (12th Street Rag) that begins with a numeric, the sorted output is correct except for that single title which appears as a zero (0), and that simply changing the "12" to "Twelf" results in sort output that is perfect in every respect. PaulThat didn't tell me exactly what I needed so I gambled and built the array with _FileReadToArray(). It works for me so I suspect the problem is in the way you called _ArraySort() You didn't check the parameters nor did you check to see if $Array[0] contained data from your file or the number of elements in the array. In the case of _FileReadTo Array it contains the number of elements. _Array Sort has a parameter for the sort start position which defaults to 0 so the size of your array also was sorted. and that would have place 12th Street Rag in position 0. You then called a loop starting at 1 "Ooooopps, Im missing a file!!". NOT. Change your _ArraySort() cal to the following and all will be well with the world again. _ArraySort($array, 0, 1) EDIT: Here is my complete test code if it helps #include <file.au3> #include <Array.au3> $iFile = @desktopDir & "\test.txt" $Array = "" _FileReadToArray($iFile, $array) _ArraySort($array, 0, 1) For $I = 1 to Ubound($array) -1 MsgBox(0, "Test", $Array[$I]) Next Edited January 29, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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