summary refs log tree commit diff stats
path: root/tests/misc/t12869.nim
blob: 054e28a038576c26372e3107f89052067f5ce107 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
discard """
  errormsg: "type mismatch: got <openArray[int], proc (x: GenericParam, y: GenericParam): auto, SortOrder>"
  line: 12
"""

import sugar
from algorithm import sorted, SortOrder

let a = 5

proc sorted*[T](a: openArray[T], key: proc(v: T): int, order = SortOrder.Ascending): seq[T] =
  sorted(a, (x, y) => key(x) < key(y), order)

echo sorted(@[9, 1, 8, 2, 6, 4, 5, 0], (x) => (a - x).abs)