1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-07-31 03:50:27 +02:00

support key param

This commit is contained in:
Justin Lin
2022-04-29 10:59:17 +08:00
parent 77f74c36ec
commit e4709ab049
3 changed files with 22 additions and 7 deletions

View File

@@ -21,6 +21,11 @@ module test_sorted() {
descending = function(e1, e2) e2 - e1;
assert(sorted([2, 1, 3, 5, 4], ascending) == [1, 2, 3, 4, 5]);
assert(sorted([2, 1, 3, 5, 4], descending) == [5, 4, 3, 2, 1]);
assert(
[[2, 0, 0], [5, 0, 0], [7, 0, 0], [9, 0, 0], [10, 0, 0]] ==
sorted([[10, 0, 0], [5, 0, 0], [7, 0, 0], [2, 0, 0], [9, 0, 0]], key = function(elem) elem.x)
);
}
test_sorted();