github.com/goplus/llgo@v0.8.3/_demo/qsort/qsort.go (about)

     1  package main
     2  
     3  import (
     4  	"unsafe"
     5  
     6  	"github.com/goplus/llgo/c"
     7  )
     8  
     9  func main() {
    10  	a := [...]int{100, 8, 23, 2, 7}
    11  	c.Qsort(c.Pointer(&a), 5, unsafe.Sizeof(0), func(a, b c.Pointer) c.Int {
    12  		return c.Int(*(*int)(a) - *(*int)(b))
    13  	})
    14  	for _, v := range a {
    15  		c.Printf(c.Str("%d\n"), v)
    16  	}
    17  }
    18  
    19  /* Expected output:
    20  2
    21  7
    22  8
    23  23
    24  100
    25  */