
-----------------------------------
Carey
Fri Mar 28, 2008 7:40 am

String Shuffler
-----------------------------------
This program scrambles an array of strings. With some modifications, can be used with any type of variable.

-----------------------------------
Carey
Mon Apr 07, 2008 7:38 am

RE:String Shuffler
-----------------------------------
Comments anyone?

-----------------------------------
Tallguy
Thu Apr 17, 2008 10:03 am

RE:String Shuffler
-----------------------------------
"some modifications" wat is ur defination of this?

-----------------------------------
repsoccer16
Mon Apr 21, 2008 7:30 am

RE:String Shuffler
-----------------------------------
ya what are the modifications that you are talking about?

-----------------------------------
Carey
Wed Apr 23, 2008 8:23 am

Re: String Shuffler
-----------------------------------
to make it sort any other type of array, just changes all the string variables into something else.

in the below example yourType is the type of variable to shuffle

note: changing the type without changing how you get and put the data will result in an error.

Example:
type yourType : string

const fileName := "Data.txt"
var phrases : flexible array 1 .. 0 of yourType
var file : int

proc getWords
    open : file, fileName, get
    loop
        exit when eof (file)
        new phrases, upper (phrases) + 1
        get : file, phrases (upper (phrases)) : *
    end loop
    close : file
end getWords

proc putWords
    open : file, "scrambled" + fileName, put
    for i : 1 .. upper (phrases)
        put : file, phrases (i)
    end for
    close : file
end putWords

procedure quickSort (var nums : array 1 .. * of real, var p : array 1 .. * of yourType, left, right : int)
    var pivotPlace : int
    var tempN : real
    var tempP : yourType
    tempN := nums (left)
    tempP := p (left)
    nums (left) := nums ((left + right) div 2)
    p (left) := p ((left + right) div 2)
    nums ((left + right) div 2) := tempN
    p ((left + right) div 2) := tempP
    var lastSmall := left
    for i : left + 1 .. right
        if nums (i) 