Added documentation
Now `isSorted` is documented.
This commit is contained in:
parent
138cf777da
commit
dc41beed5a
1 changed files with 3 additions and 0 deletions
|
|
@ -240,6 +240,9 @@ template sortedByIt*(seq1, op: expr): expr =
|
||||||
proc isSorted*[T](a: openarray[T],
|
proc isSorted*[T](a: openarray[T],
|
||||||
cmp: proc(x, y: T): int {.closure.},
|
cmp: proc(x, y: T): int {.closure.},
|
||||||
order = SortOrder.Ascending): bool =
|
order = SortOrder.Ascending): bool =
|
||||||
|
## Checks to see whether `a` is already sorted in `order`
|
||||||
|
## using `cmp` for the comparison. Parameters identical
|
||||||
|
## to `sort`
|
||||||
result = true
|
result = true
|
||||||
for i in 0..<len(a)-1:
|
for i in 0..<len(a)-1:
|
||||||
if cmp(a[i],a[i+1]) * order > 0:
|
if cmp(a[i],a[i+1]) * order > 0:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue