tsystemcmp.nim 471 B

12345678910111213141516171819202122232425
  1. discard """
  2. cmd: r"nim c --hints:on $options --threads:on $file"
  3. output: '''@["", "a", "ha", "hi", "ho", "huu"]'''
  4. """
  5. import algorithm
  6. # bug #1657
  7. var modules = @["hi", "ho", "", "a", "ha", "huu"]
  8. sort(modules, system.cmp)
  9. echo modules
  10. type
  11. MyType = object
  12. x: string
  13. proc cmp(a, b: MyType): int = cmp(a.x, b.x)
  14. var modulesB = @[MyType(x: "ho"), MyType(x: "ha")]
  15. sort(modulesB, cmp)
  16. # bug #2397
  17. proc f(x: (proc(a,b: string): int) = system.cmp) = discard