[Gambas-user] How to sort an array?

ron ronstk at ...239...
Fri Feb 13 17:15:34 CET 2004


On Friday 13 February 2004 16:23, adam krell wrote:
> Is there an easy way to sort an array of integers?
> I'd do it in a columnview column but it only sorts
> text alphanumerically, I believe.
>
> Thanks,
>
> Adam

The simplest way is to make the content of the column cell say 20 char
when you write into the cell use right$(Space$(20),Cstr(you_integer_value),20)
This makes the sort ok.


PUBLIC SUB fillcv()
  DIM x AS Integer
  DIM sp AS Integer
  sp=6

  columnview1.columns.count=2
  FOR x=0 TO 50
    columnview1.add(x, Right$(Space$(sp) & CInt(Rnd()*100),sp) )
  NEXT
  
  columnview1.columns.sort=0'TRUE 'columnviewcolun
END


--- 
Ron





More information about the User mailing list