t12869.nim 401 B

123456789101112131415
  1. discard """
  2. errormsg: "type mismatch: got <openArray[int], proc (x: GenericParam, y: GenericParam): auto, SortOrder>"
  3. line: 12
  4. """
  5. import sugar
  6. from algorithm import sorted, SortOrder
  7. let a = 5
  8. proc sorted*[T](a: openArray[T], key: proc(v: T): int, order = SortOrder.Ascending): seq[T] =
  9. sorted(a, (x, y) => key(x) < key(y), order)
  10. echo sorted(@[9, 1, 8, 2, 6, 4, 5, 0], (x) => (a - x).abs)