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