gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/gdt-plot.lua
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2013年02月05日 10:20:36 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2013年02月05日 10:20:36 +0100
commitdac5106531534f5dbc7e223a30acbdc7a8c686ca (patch)
treecfa08ecf63ffcc6b397f30bdaf24cc0a9f12d544 /gdt-plot.lua
parentfd774f79da279888d48728d95d6009594ddf63ad (diff)
downloadgsl-shell-dac5106531534f5dbc7e223a30acbdc7a8c686ca.tar.gz
Add sorting with labels in gdt reduce function
Diffstat (limited to 'gdt-plot.lua')
-rw-r--r--gdt-plot.lua 42
1 files changed, 42 insertions, 0 deletions
diff --git a/gdt-plot.lua b/gdt-plot.lua
index 99322be7..073b0f44 100644
--- a/gdt-plot.lua
+++ b/gdt-plot.lua
@@ -47,6 +47,46 @@ local stat_lookup = {
count = {f = function(accu, x, n) return n end},
}
+local function quicksort_mirror(t, f, mirror)
+
+ local function quicksort(start, endi)
+ if start >= endi then return end
+ local pivot = start
+ for i = start + 1, endi do
+ if f(t[i], t[pivot]) then
+ local temp = t[pivot + 1]
+ local temp_m = mirror[pivot + 1]
+ t[pivot + 1] = t[pivot]
+ mirror[pivot + 1] = mirror[pivot]
+ if(i == pivot + 1) then
+ t[pivot] = temp
+ mirror[pivot] = temp_m
+ else
+ t[pivot] = t[i]
+ t[i] = temp
+ mirror[pivot] = mirror[i]
+ mirror[i] = temp_m
+ end
+ pivot = pivot + 1
+ end
+ end
+
+ quicksort(start, pivot - 1)
+ quicksort(pivot + 1, endi)
+ end
+
+ quicksort(1, #t)
+end
+
+local function sort_labels_func(lab_a, lab_b)
+ local n = #lab_a
+ for k = 1, n do
+ local a, b = lab_a[k], lab_b[k]
+ if a ~= b then return a < b end
+ end
+ return false
+end
+
local function compare_list(a, b)
local n = #a
for k = 1, n do
@@ -152,6 +192,8 @@ local function rect_funcbin(t, jxs, jys, jes)
end
end
+ quicksort_mirror(labels, sort_labels_func, val)
+
return labels, enums, val
end
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月17日 10:31:24 +0000

AltStyle によって変換されたページ (->オリジナル) /