t12869.nim 352 B

123456789101112131415
  1. discard """
  2. errormsg: "type mismatch: got <bool> but expected 'int'"
  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)