Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
a := [4, 65, 2, -31, 0, 99, 83, 782, 7]
|
||||
for k, v in QuickSort(a)
|
||||
Out .= "," v
|
||||
MsgBox, % SubStr(Out, 2)
|
||||
return
|
||||
|
||||
QuickSort(a)
|
||||
{
|
||||
if (a.MaxIndex() <= 1)
|
||||
return a
|
||||
Less := [], Same := [], More := []
|
||||
Pivot := a[1]
|
||||
for k, v in a
|
||||
{
|
||||
if (v < Pivot)
|
||||
less.Insert(v)
|
||||
else if (v > Pivot)
|
||||
more.Insert(v)
|
||||
else
|
||||
same.Insert(v)
|
||||
}
|
||||
Less := QuickSort(Less)
|
||||
Out := QuickSort(More)
|
||||
if (Same.MaxIndex())
|
||||
Out.Insert(1, Same*) ; insert all values of same at index 1
|
||||
if (Less.MaxIndex())
|
||||
Out.Insert(1, Less*) ; insert all values of less at index 1
|
||||
return Out
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
MsgBox % quicksort("8,4,9,2,1")
|
||||
|
||||
quicksort(list)
|
||||
{
|
||||
StringSplit, list, list, `,
|
||||
If (list0 <= 1)
|
||||
Return list
|
||||
pivot := list1
|
||||
Loop, Parse, list, `,
|
||||
{
|
||||
If (A_LoopField < pivot)
|
||||
less = %less%,%A_LoopField%
|
||||
Else If (A_LoopField > pivot)
|
||||
more = %more%,%A_LoopField%
|
||||
Else
|
||||
pivotlist = %pivotlist%,%A_LoopField%
|
||||
}
|
||||
StringTrimLeft, less, less, 1
|
||||
StringTrimLeft, more, more, 1
|
||||
StringTrimLeft, pivotList, pivotList, 1
|
||||
less := quicksort(less)
|
||||
more := quicksort(more)
|
||||
Return less . pivotList . more
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue