`ref` means that it's a managed reference, so you need to dereference it (see 
[https://nim-lang.org/docs/manual.html#types-reference-and-pointer-types)](https://nim-lang.org/docs/manual.html#types-reference-and-pointer-types\)).
 
    
    
    import random
    import algorithm
    
    const
      els = 10_000_000
      maxval = 1_000_000
    
    type E = tuple
      r: int32
      i: int32
    
    proc main() =
      var a: ref array[els, E]
      new(a)
      
      for i in 0..high(a[]):
        a[i].r = int32(rand(maxval))
        a[i].i = int32(i)
      a[].sort()
      echo a[0..<5], " ... ", a[^5..^1]
    
    main()
    
    
    Run

Reply via email to