diff options
| author | Alexander Gavrilov | 2012-04-22 19:22:00 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-04-22 19:22:00 +0400 |
| commit | 125cd6622a1d2ce7a8dfa7caf40a85049baf4977 (patch) | |
| tree | 033aa194ef7f969f88a2675337ca9cca2f27cd43 /library/lua | |
| parent | 2ef321a2086f03de30d184c06c527f504893cd07 (diff) | |
| download | dfhack-125cd6622a1d2ce7a8dfa7caf40a85049baf4977.tar.gz dfhack-125cd6622a1d2ce7a8dfa7caf40a85049baf4977.tar.bz2 dfhack-125cd6622a1d2ce7a8dfa7caf40a85049baf4977.tar.xz | |
Support sorting units in many more ui contexts.
Diffstat (limited to 'library/lua')
| -rw-r--r-- | library/lua/utils.lua | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/library/lua/utils.lua b/library/lua/utils.lua index 3becdbb6..00e42f9d 100644 --- a/library/lua/utils.lua +++ b/library/lua/utils.lua @@ -49,6 +49,7 @@ function make_sort_order(data,ordering) -- Compute sort keys and comparators local keys = {} local cmps = {} + local size = data.n or #data for i=1,#ordering do local order = ordering[i] @@ -58,7 +59,7 @@ function make_sort_order(data,ordering) elseif order.key then local kt = {} local kf = order.key - for j=1,#data do + for j=1,size do if data[j] == nil then kt[j] = nil else @@ -75,7 +76,7 @@ function make_sort_order(data,ordering) -- Make an order table local index = {} - for i=1,#data do + for i=1,size do index[i] = i end |
