Zeilen in .txt durcheinander bringen

  • Guten Abend!
    Ich habe ein kleines Problem, undzwar möchte ich in einer .txt Datei mit 650 Zeilen, diese Zeilen durcheinander bringen. Es handelt sich hierbei um einen Mapcycle von CSPSP, der Alphabetisch geordnet ist. Allerdings sind dann z.B. alle AWP Maps hintereinander, und das möchte ich nicht. Ich weiß nicht wo ich anfangen soll. Ich dachte irgendwie an soetwas Ähnliches, als wenn man jede Zeile ausliest und in eine Andere schreibt.
    Könnt ihr mir da vielleicht helfen? Und bevor nachgefragt wird: Einen Code zum posten habe ich noch nicht.

  • Mal was ganz simples.

    [autoit]

    #include <Array.au3>

    [/autoit][autoit][/autoit][autoit]

    ;Global $sPath = "c:\irgendwas"
    ;Global $aFile
    ;_FileReadToArray($sPath, $aFile)
    ;_ArrayDelete($aFile, 0)

    [/autoit][autoit][/autoit][autoit]

    Dim $aFile[4] = ["hallo", "welt", "foo", "bar"]

    [/autoit][autoit][/autoit][autoit]

    _shuffleUpAndDeal($aFile)

    [/autoit][autoit][/autoit][autoit]

    Func _shuffleUpAndDeal(ByRef $aArray)
    $j = UBound($aFile) -1 + Random(100,200,1)
    For $i = 0 To $j
    do
    $a = Random(0, UBound($aFile)-1, 1)
    $b = Random(0, UBound($aFile)-1, 1)
    Until $a <> $b
    _ArraySwap($aFile[$a], $aFile[$b])
    Next
    EndFunc

    [/autoit][autoit][/autoit][autoit]

    _ArrayDisplay($aFile)

    [/autoit]


    Ich hatte Spass :)

    edit:
    Nein, ernsthaft:

    Spoiler anzeigen
    [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _ArrayRandom
    ; Description ...: Randomize the row order of (part of) a 1D or 2D array.
    ; Syntax.........: _ArrayRandom(ByRef $avArray, $iStart = 0, $iEnd = 0)
    ; Parameters ....: $avArray - Array to randomize
    ; $iStart - [optional] Index of array to start at
    ; $iEnd - [optional] Index of array to stop at
    ; Return values .: Success - 1
    ; Failure - 0, sets @error:
    ; |1 - $avArray is not an array
    ; |2 - $iStart is greater than $iEnd
    ; Author ........: Tom Vernooij
    ; Modified.......:
    ; Remarks .......: Based on Yashied's method
    ; Related .......:
    ; Link ..........:
    ; Example .......: No
    ; ===============================================================================================================================
    Func _ArrayRandom(ByRef $avArray, $iStart=0, $iEnd=0)
    If Not IsArray($avArray) Then Return SetError(1,0,0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iRow, $iCol, $rRow, $Temp, $numCols = UBound($avArray,2), $Ubound = UBound($avArray) -1

    [/autoit] [autoit][/autoit] [autoit]

    ; Bounds checking
    If $iEnd < 1 Or $iEnd > $UBound Then $iEnd = $UBound
    If $iStart < 0 Then $iStart = 0
    If $iStart > $iEnd Then Return SetError(2, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; for 2 dimentional arrays:
    If $numCols Then
    For $iRow = $iStart To $iEnd ;for each row...
    $rRow = Random($iStart, $iEnd, 1) ;...select a random row
    For $iCol = 0 To $numCols -1 ;swich the values for each cell in the rows
    $Temp = $avArray[$iRow][$iCol]
    $avArray[$iRow][$iCol] = $avArray[$rRow][$iCol]
    $avArray[$rRow][$iCol] = $Temp
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ; for 1 dimentional arrays:
    Else
    For $iRow = $iStart To $iEnd ;for each cell...
    $rRow = Random($iStart, $iEnd, 1) ;...select a random cell
    $Temp = $avArray[$iRow] ;switch the values in the cells
    $avArray[$iRow] = $avArray[$rRow]
    $avArray[$rRow] = $Temp
    Next
    EndIf
    Return 1
    EndFunc

    [/autoit]
  • Also er sagt mit jetzt dass er die Funktion _FileReadToArray() nicht finden kann.
    Ich habe sie in meiner Array.au3 auch nicht gefunden. Ist das normal?