qsort from karmai thread contract paper