Skip to content

Commit 1c7d0a1

Browse files
committed
Fix Luacheck warning
1 parent 9bcdc06 commit 1c7d0a1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/sorting/mergesort.lua

+13-13
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ return function(
88
return a < b
99
end
1010
-- Merges two sorted lists; elements of a come before those of b
11-
local function merge(result, list, other_list)
11+
local function merge(result, list_1, list_2)
1212
local result_index = 1
13-
local index = 1
14-
local other_index = 1
15-
while index <= #list and other_index <= #other_list do
13+
local index_1 = 1
14+
local index_2 = 1
15+
while index_1 <= #list_1 and index_2 <= #list_2 do
1616
-- Compare "head" element, insert "winner"
17-
if less_than(other_list[other_index], list[index]) then
18-
result[result_index] = other_list[other_index]
19-
other_index = other_index + 1
17+
if less_than(list_2[index_2], list_1[index_1]) then
18+
result[result_index] = list_2[index_2]
19+
index_2 = index_2 + 1
2020
else
21-
result[result_index] = list[index]
22-
index = index + 1
21+
result[result_index] = list_1[index_1]
22+
index_1 = index_1 + 1
2323
end
2424
result_index = result_index + 1
2525
end
2626
-- Add remaining elements of either list or other_list
27-
for offset = 0, #list - index do
28-
result[result_index + offset] = list[index + offset]
27+
for offset = 0, #list_1 - index_1 do
28+
result[result_index + offset] = list_1[index_1 + offset]
2929
end
30-
for offset = 0, #other_list - other_index do
31-
result[result_index + offset] = other_list[other_index + offset]
30+
for offset = 0, #list_2 - index_2 do
31+
result[result_index + offset] = list_2[index_2 + offset]
3232
end
3333
end
3434

0 commit comments

Comments
 (0)