nitekram Posted October 6, 2008 Share Posted October 6, 2008 _ArraySort() does not work for this type of sort - lets say I want to bypass the first char or number in the data and then sort the array based on the second or third, ect. Does anyone know how to do this or does someone know of another function that will allow me to chose which char to sort by? IE. array contains numbers 123,223,224,512 - sorting by second char I want it to come out 512,123,223,224 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
martin Posted October 6, 2008 Share Posted October 6, 2008 _ArraySort() does not work for this type of sort - lets say I want to bypass the first char or number in the data and then sort the array based on the second or third, ect. Does anyone know how to do this or does someone know of another function that will allow me to chose which char to sort by? IE. array contains numbers 123,223,224,512 - sorting by second char I want it to come out 512,123,223,224Maybe like this #include <array.au3> Dim $arr1[4] = [123,223,224,512] _arraysort($arr1) Local $arr2[UBound($arr1)] for $n = 0 to Ubound($arr1) - 1 $str = String($arr1[$n]) $arr2[$n] = stringright($str,StringLen($str) - 1) & StringLeft($str,1) Next _ArraySort($arr2) for $n = 0 to Ubound($arr1) - 1 $arr1[$n] = Number(StringRight($arr2[$n],1) & stringLeft($arr2[$n],StringLen($arr2[$n]) - 1) ) Next _ArrayDisplay($arr1) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
nitekram Posted October 6, 2008 Author Share Posted October 6, 2008 Maybe like this #include <array.au3> Dim $arr1[4] = [123,223,224,512] _arraysort($arr1) Local $arr2[UBound($arr1)] for $n = 0 to Ubound($arr1) - 1 $str = String($arr1[$n]) $arr2[$n] = stringright($str,StringLen($str) - 1) & StringLeft($str,1) Next _ArraySort($arr2) for $n = 0 to Ubound($arr1) - 1 $arr1[$n] = Number(StringRight($arr2[$n],1) & stringLeft($arr2[$n],StringLen($arr2[$n]) - 1) ) Next _ArrayDisplay($arr1)Never would have thought of doing it that way, nor would I have been able to do it once I thought about it. Good work and thanks for your help!!! 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator 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