From b8875bc5e980c117d56004a426839da4979798e3 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 7 Feb 2021 16:23:08 +0800 Subject: [PATCH] rename param --- src/util/_impl/_sort_impl.scad | 8 ++++---- src/util/sort.scad | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/_impl/_sort_impl.scad b/src/util/_impl/_sort_impl.scad index a6934a08..b7ef2396 100644 --- a/src/util/_impl/_sort_impl.scad +++ b/src/util/_impl/_sort_impl.scad @@ -27,12 +27,12 @@ function _sort_by(lt, by, idx) = ) _sort_by_idx(lt, i); -function _sort_by_comp(lt, comp) = +function _sort_by_cmp(lt, cmp) = let(leng = len(lt)) leng <= 1 ? lt : let( pivot = lt[0], - before = [for(j = 1; j < leng; j = j + 1) if(comp(lt[j], pivot) < 0) lt[j]], - after = [for(j = 1; j < leng; j = j + 1) if(comp(lt[j], pivot) >= 0) lt[j]] + before = [for(j = 1; j < leng; j = j + 1) if(cmp(lt[j], pivot) < 0) lt[j]], + after = [for(j = 1; j < leng; j = j + 1) if(cmp(lt[j], pivot) >= 0) lt[j]] ) - concat(_sort_by_comp(before, comp), [pivot], _sort_by_comp(after, comp)); \ No newline at end of file + concat(_sort_by_cmp(before, cmp), [pivot], _sort_by_cmp(after, cmp)); \ No newline at end of file diff --git a/src/util/sort.scad b/src/util/sort.scad index 8cb70c06..948446ee 100644 --- a/src/util/sort.scad +++ b/src/util/sort.scad @@ -11,6 +11,6 @@ use <_impl/_sort_impl.scad>; function sort(lt, by = "idx", idx = 0) = - is_function(by) ? _sort_by_comp(lt, by) : // support function literal + is_function(by) ? _sort_by_cmp(lt, by) : // support function literal by == "vt" ? _vt_sort(lt) : // for example, sort by zyx for a list of points _sort_by(lt, by, idx); \ No newline at end of file