linvin001 Posted December 12, 2014 Share Posted December 12, 2014 hi, im a beginner. I need some help with array sorting. I try to sort a 1d array to new arrays with the same number of element So here is what I did,but it doesnot work #include <Array.au3> Local $aDays = StringSplit("Mon,Tues,Wed,Thur,Fri,Sat,Sun", ",") Local $count=0 local $array[50][3] For $j = 0 To $aDays[0]/3 for $k=0 to UBound($array, 3) - 1 if $count< $aDays[0] then $h=$count - 3*$j $array[ $j ][$h ] = $aDays[ $count ] $count+=$count EndIf Next next _ArrayDisplay($aDays) _ArrayDisplay($array) i want to sort them into arrays with 3 elements, like[Mon,Tues,Wed],[Thur,Fri,Sat],[sun,Mon,Tues], etc Thanks Link to comment Share on other sites More sharing options...
Malkey Posted December 12, 2014 Share Posted December 12, 2014 Is this what you are trying to do? #include <Array.au3> Local $aDays = StringSplit("Mon,Tues,Wed,Thur,Fri,Sat,Sun", ",", 3) Local $array[50][3] For $k = 0 To UBound($array) - 1 For $j = 0 To 2 $array[$k][$j] = $aDays[Mod(($k * 3) + $j, 7)] Next Next _ArrayDisplay($aDays) _ArrayDisplay($array) linvin001 1 Link to comment Share on other sites More sharing options...
Geir1983 Posted December 12, 2014 Share Posted December 12, 2014 This what you trying to do? #include <Array.au3> Local $aDays = StringSplit("Mon,Tues,Wed,Thur,Fri,Sat,Sun", ",", 2) Local $count=0 local $array[50][3] For $j = 0 To Ubound($array, 1) -1 For $k=0 to UBound($array, 2) - 1 $array[$j][$k] = $aDays[Mod($count, 7)] $count= $count + 1 Next Next _ArrayDisplay($aDays) _ArrayDisplay($array) linvin001 1 Link to comment Share on other sites More sharing options...
linvin001 Posted December 12, 2014 Author Share Posted December 12, 2014 Thank you for both of you. it works great 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