Sign in to follow this  
Followers 0
rakudave

stringsort ?

7 posts in this topic




#2 ·  Posted (edited)

edit... I was thinking of something else....

Edited 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]

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 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.

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 :P

Edited 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]

Share this post


Link to post
Share on other sites

#7 ·  Posted (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

easiest 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 by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0