rakudave Posted December 12, 2005 Posted December 12, 2005 (edited) i hope i don't bore you but i found nothing in the helpfile or forum... i've got a string like "869475231" and i'd like to sort it, like "123456789" => how do i do this ??? thx Edited December 12, 2005 by rakudave Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table
SpookMeister Posted December 12, 2005 Posted December 12, 2005 (edited) edit... I was thinking of something else.... Edited December 12, 2005 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
SpookMeister Posted December 12, 2005 Posted December 12, 2005 is it always going to be numbers? [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
GaryFrost Posted December 12, 2005 Posted December 12, 2005 (edited) #include <Array.au3> $s_test = "869475231" $a_test = StringSplit($s_test,"") _ArrayDelete($a_test,0) _ArraySort($a_test) ;~ _ArrayDisplay($a_test,"test") $s_test = "" for $x = 0 To UBound($a_test) - 1 $s_test = $s_test & $a_test[$x] Next MsgBox(0,"sorted",$s_test) Edited December 12, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
SpookMeister Posted December 12, 2005 Posted December 12, 2005 (edited) You might put the string into an array character by character, then sort the array with _ArraySort then put it back into a string.Edit... like gafrost just sugested Edited December 12, 2005 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
rakudave Posted December 12, 2005 Author Posted December 12, 2005 ah, ok thx Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table
seandisanti Posted December 12, 2005 Posted December 12, 2005 (edited) i hope i don't bore you but i found nothing in the helpfile or forum... i've got a string like "869475231" and i'd like to sort it, like "123456789" => how do i do this ??? thxeasiest way would probably be: #include<array.au3> Dim $blah $string = "987654321" $blah = StringSplit($string,"") _ArraySort($blah,0,1) $tmp = "" For $x = 1 to $blah[0] $tmp = $tmp & $blah[$x] Next MsgBox(0,"Output",$tmp) should be able to use _ArrayToString() to convert it back, but it never works for me so i just do it with my own loop ***edit** looks like gary beat me to it Edited December 12, 2005 by cameronsdad
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