mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 01:04:07 +02:00
rename param
This commit is contained in:
@@ -27,12 +27,12 @@ function _sort_by(lt, by, idx) =
|
|||||||
)
|
)
|
||||||
_sort_by_idx(lt, i);
|
_sort_by_idx(lt, i);
|
||||||
|
|
||||||
function _sort_by_comp(lt, comp) =
|
function _sort_by_cmp(lt, cmp) =
|
||||||
let(leng = len(lt))
|
let(leng = len(lt))
|
||||||
leng <= 1 ? lt :
|
leng <= 1 ? lt :
|
||||||
let(
|
let(
|
||||||
pivot = lt[0],
|
pivot = lt[0],
|
||||||
before = [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(comp(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>;
|
use <_impl/_sort_impl.scad>;
|
||||||
|
|
||||||
function sort(lt, by = "idx", idx = 0) =
|
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
|
by == "vt" ? _vt_sort(lt) : // for example, sort by zyx for a list of points
|
||||||
_sort_by(lt, by, idx);
|
_sort_by(lt, by, idx);
|
Reference in New Issue
Block a user