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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# table (tables and sorting)
> out of date!!
## sorting
|name|accepted types|type of sorting|order|
|---|---|---|---|
|quicksort| double,int | comparison | greatest -> least |
|mergesort| double,int | comparison | greatest -> least |
|shellsort| double,int | comparison | greatest -> least |
|bubblesort| double,int | comparison | greatest -> least |
|heapsort| double,int | comparison | greatest -> least |
|countingsort| int | non-comparison | least -> greatest|
|miraclesort| double,int | esoteric | ? greatest -> least |
|stalinsort| double,int | esoteric | greatest -> least |
|slowsort| double,int | esoteric | greatest -> least |
|bogosort| double,int | esoteric | greatest -> least |
### usage
```lua
local test = {5, 10, 922, -32, 554, 0};
locla test_sorted = llib.array.mergesort(test); -- 922, 554, 10, 5, 0, -32
```
## utils
### len
'accepts any table
returns length of table, including associative arrays
```lua
llib.array.len({a = 55, b = 22}); -- 2
```
### reverse
'accepts any table
reverses a table
```lua
llib.array.reverse({5, 4, 22}) -- 22, 4, 5
```
### least/greatest
'accepts a table with numbers
gets smallest/largest value of a table
```lua
llib.array.greatest({22, 99, 99.9}) -- 99.9
```
### shuffle
'accepts any table
randomizes array
```lua
llib.array.shuffle({5, 22, 89}) -- 22, 89, 5
```
### sum
'accepts a table with numbers
gets sum of each element in a table
```lua
llib.array.sum({5, 4, 3}) --12
```
### index
'accepts any table and a value
gets index of item in array linearly, returns -1 if not present
```lua
llib.array.index({5, 4, 3}, 4) -- 2
```
### sindex
'accepts a sorted table with numbers and a value
gets index through binary search, -1 if not present
```lua
llib.array.sindex({2, 4, 8}, 8) -- 3
```
### split
'accepts a string and a delimiter
splits a string by arg2, returns a array
```lua
llib.array.split("hello world"," ") -- "hello", "world"
```
### to_char_array
'accepts a string
returns a char array from a string
```lua
llib.array.to_char_array("meow") -- "m", "e", "o", "w"
```
|