"a1,a2,a3,a4,a5.......b1,b2,b3......c1,c2,c3.......c19,c20"

I understand _ArrayPermute(), yet the only orders I'm interested in must consist of have each series of numbers for each letter in order. Like: "a1,b1,a2,a3,c1....." and so forth. Not "a1,b1,a3,c1,a2" as "a3" is before "a2"

First off, I've made a work around so I don't recieve the error of exceeded array limit when using _ArrayPermute(). I made the function write to a .txt file instead of saving everything in array. Yet this would create a very very large file, which would be a problem opening. Therefore, I created an additional function to "check" the order where the numbers are in order. Now to the question I need help in. Is it possible to rewrite this so the script computes faster?

Here is my redone _ArrayPermute() and _ArrayExeterInternal()

Func ArrayPermute(ByRef $avArray, $sDelim = ",") If Not IsArray($avArray) Then Return SetError(1, 0, 0) If UBound($avArray, 0) <> 1 Then Return SetError(2, 0, 0) Local $iSize = UBound($avArray), $aIdx[$iSize], $aResult="" For $i = 0 To $iSize - 1 $aIdx[$i] = $i Next Array_ExeterInternal($avArray, 0, $iSize, $sDelim, $aIdx, $aResult) EndFunc

Func Array_ExeterInternal(ByRef $avArray, $iStart, $iSize, $sDelim, ByRef $aIdx, ByRef $aResult) If $iStart == $iSize - 1 Then For $i = 0 To $iSize - 1 $aResult &= $avArray[$aIdx[$i]] & $sDelim Next If $sDelim <> "" Then $aResult = StringTrimRight($aResult, 1) If CheckOrder($aResult) Then FileWriteLine($file, $aResult) $aResult = "" Else Local $iTemp For $i = $iStart To $iSize - 1 $iTemp = $aIdx[$i] $aIdx[$i] = $aIdx[$iStart] $aIdx[$iStart] = $iTemp Array_ExeterInternal($avArray, $iStart + 1, $iSize, $sDelim, $aIdx, $aResult) $aIdx[$iStart] = $aIdx[$i] $aIdx[$i] = $iTemp Next EndIf EndFunc

And my checkorder()

Func CheckOrder($string) Local $test = StringSplit($string, ",", 2) $t = 0 $acounter=0 $bcounter = 0 $ccounter = 0 While $t < UBound($test) $subtarray = StringSplit($test[$t],"",2) $stringt = StringTrimLeft($test[$t], 1) $int = Int($stringt) - 1 If $subtarray[0] = "m" And $int = $acounter Then $acounter = $acounter + 1 ElseIf $subtarray[0] = "c" And $int = $bcounter Then $bcounter = $bcounter + 1 ElseIf $subtarray[0] = "d" And $int = $ccounter Then $ccounter = $ccounter + 1 Else Return False EndIf $t = $t + 1 WEnd Return True EndFunc

Oh, and there are 20 numbers to each letter. Your help will be much appreciated.

**Edited by jb09, 06 March 2012 - 11:55 AM.**