mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-18 22:58:04 +01:00
rename param
This commit is contained in:
parent
4ef405a732
commit
f5f38c8934
@ -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));
|
||||
concat(_sort_by_cmp(before, cmp), [pivot], _sort_by_cmp(after, cmp));
|
@ -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);
|
Loading…
x
Reference in New Issue
Block a user