From 774229e3f9eb2684218a21d5551f5d0d09974b4f Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sat, 29 Jun 2019 10:29:43 +0800 Subject: [PATCH] add doc --- docs/lib2-sort.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docs/lib2-sort.md diff --git a/docs/lib2-sort.md b/docs/lib2-sort.md new file mode 100644 index 00000000..f7dd940b --- /dev/null +++ b/docs/lib2-sort.md @@ -0,0 +1,32 @@ +# sort + +Sorts the elements of a list in ascending order. The list is a list-of-list construct, such as `[[a0, a1, a2...], [b0, b1, b2,...], [c0, c1, c2,...],...]`. When sorting, the function looks only at one index position of each sublist. + +**Since: ** 2.0 + +## Parameters + +- `lt` : The original list. +- `by` : Can be `"x"`、`"y"`、`"z"`, or `"idx"` (Default). +- `idx` : When `by` is `"idx"`, the value of `idx` is used. The Default value is 0. + +## Examples + + include ; + + assert( + [[2, 0, 0], [5, 0, 0], [7, 0, 0], [9, 0, 0], [10, 0, 0]] == + sort([[10, 0, 0], [5, 0, 0], [7, 0, 0], [2, 0, 0], [9, 0, 0]]) + ); + + assert( + [[2, 0, 0], [5, 0, 0], [7, 0, 0], [9, 0, 0], [10, 0, 0]] == + sort([[10, 0, 0], [5, 0, 0], [7, 0, 0], [2, 0, 0], [9, 0, 0]], by = "x") + ); + + assert( + [[0, 2, 0], [0, 5, 0], [0, 7, 0], [0, 9, 0], [0, 10, 0]] == + sort([[0, 10, 0], [0, 5, 0], [0, 7, 0], [0, 2, 0], [0, 9, 0]], by = "idx", idx = 1) + ); + +