diff options
author | Grzegorz Adam Hankiewicz <gradha@imap.cc> | 2014-06-06 19:32:36 +0200 |
---|---|---|
committer | Grzegorz Adam Hankiewicz <gradha@imap.cc> | 2014-06-06 19:32:36 +0200 |
commit | 7da3c5e71e485ef4326dcf415a297267a47ab971 (patch) | |
tree | 6ecb9cff305a8387e1163ef7344b61c335da0471 | |
parent | 6975e77d43de640d9d0ca933fe64dc6d2f161b97 (diff) | |
download | Nim-7da3c5e71e485ef4326dcf415a297267a47ab971.tar.gz |
Adds do notation example to algorithm.sort.
-rw-r--r-- | lib/pure/algorithm.nim | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/pure/algorithm.nim b/lib/pure/algorithm.nim index 37fbc948c..86d329763 100644 --- a/lib/pure/algorithm.nim +++ b/lib/pure/algorithm.nim @@ -150,6 +150,15 @@ proc sort*[T](a: var openArray[T], ## # overload: ## sort(myStrArray, system.cmp) ## + ## You can inline adhoc comparison procs with the `do notation + ## <manual.html#do-notation>`_. Example: + ## + ## .. code-block:: nimrod + ## + ## people.sort do (x, y: Person) -> int: + ## result = cmp(x.surname, y.surname) + ## if result == 0: + ## result = cmp(x.name, y.name) var n = a.len var b: seq[T] newSeq(b, n div 2) |