# array sorting problem

## 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 \$count=0
local \$array[50][3]

For \$j = 0 To \$aDays[0]/3
for \$k=0 to UBound(\$array, 3) - 1
\$h=\$count - 3*\$j
\$array[ \$j ][\$h ] = \$aDays[ \$count ]
\$count+=\$count
EndIf
Next
next
_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 on other sites

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(\$array)```

##### 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
\$count= \$count + 1
Next
Next

_ArrayDisplay(\$array)```

##### Share on other sites

Thank you for both of you. it works great

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...