Jump to content
Sign in to follow this  
linvin001

array sorting problem

Recommended Posts

linvin001

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

Share this post


Link to post
Share on other sites
Geir1983

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)
  • Like 1

Share this post


Link to post
Share on other sites
linvin001

Thank you for both of you. it works great

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  

×