forked from Ixiko/AHK-libs-and-classes-collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandomiseArray.ahk
39 lines (36 loc) · 851 Bytes
/
RandomiseArray.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
randomiseArray(byRef a)
{
for index, value in a
out .= value "-" index "|" ; "-" allows for sort to work with just the value
; out will look like: value-index|value-index|
v := a[a.minIndex()]
if v is number
type := " N "
StringTrimRight, out, out, 1 ; remove trailing |
Sort, out, % "D| " type "Random"
aStorage := []
loop, parse, out, |
{
StringSplit, split, A_LoopField, -
; split1 = value, split2 = index
aStorage.insert(a[split2])
}
a := aStorage
return
}
/*
RandomiseArray(byref a)
{
aIndicies := []
for i, in a
aIndicies.insert(i)
for index, in a
{
Random, i, 1, aIndicies.MaxIndex()
storage := a[aIndicies[i]]
, a[aIndicies[i]] := a[index]
, a[index] := storage
}
return
}
*/