topten Posted November 18, 2014 Posted November 18, 2014 I have some data of numbers $mydata = "10,2000,300,400,500,550" I asign it into array via regexp, then I sort it with _arraysort and as the result I get that 550 is the biggest number here! What am I doing wrong? Result of console write is 550 500 400 300 2000 10 #include <array.au3> Global $arr[6] $mydata = "10,2000,300,400,500,550" $array1 = StringRegExp($mydata, '(\d+)', 3) for $i = 0 to UBound ($array1)-1 $arr[$i] = $array1[$i] next _ArraySort($arr,1) for $z = 0 to UBound ($arr)-1 ConsoleWrite ($arr[$z]&@CRLF) next
Moderators SmOke_N Posted November 18, 2014 Moderators Posted November 18, 2014 You're sorting a "string" (thus StringRegExp), so it sorts based on that char 1 vs char 2 etc. You're also sorting descending, you need to sort ascending. #include <array.au3> $mydata = "10,2000,300,400,500,550" $array1 = StringRegExp($mydata, '(\d+)', 3) Global $arr[UBound($array1)] for $i = 0 to UBound ($array1)-1 $arr[$i] = Int($array1[$i]) next _ArraySort($arr) _ArrayDisplay($arr) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
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