That has to do with the fact that lambdas in Nim are not as great as in other
languages. This is how I got it to compile:
proc cmp(a, b: int): int =
(a > b).int - (a < b).int
proc quicksort(a: var openarray[int]; left, right: int; cp: proc (a, b:
int): int) =
proc qsort(a: var openarray[int]; left, right: int) =
var l, r, p: int
let len = right - left
let len2 = len div 2
if true: # insertion sort on tiny array
for i in left + 1 .. right:
for j in countdown(i, left + 1):
if cp(a[j], a[j - 1]) >= 0: break # this is the line with error
swap(a[j], a[j - 1])
return
qsort(a, a.low, a.high)
var
x: array[2e6.int, int]
quicksort(x, x.low, x.high, cmp)