Jump to content

array sorting problem


 Share

Recommended Posts

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

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)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...