[Gambas-user] How to sort an array?

Joao Pinto Lamego at ...99...
Fri Feb 13 19:44:38 CET 2004


Hello,
adding spaces to tranforst an ascii sort into a numeric sort is kind of 
insane.

You should implement one of the serval known sort mechanisms like you 
can/should do on any language.

You can check them at:
http://linux.wku.edu/~lamonml/algor/sort/sort.html

The easiest to implement is "Bubble sort", if you need some help with 
the code I cand send an example.

Easiter than that just waiting for a sort type propertie on the listbox 
component to set numerical sort, but I dont think thats a common feature 
on a listbox :)

Best regards,

João Luís Marques Pinto
PTlink Technical Administrator
Lamego at ...99...
http://www.ptlink.net



ron wrote:

>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
>
>
>
>-------------------------------------------------------
>SF.Net is sponsored by: Speed Start Your Linux Apps Now.
>Build and deploy apps & Web services for Linux with
>a free DVD software kit from IBM. Click Now!
>http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
>_______________________________________________
>Gambas-user mailing list
>Gambas-user at lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/gambas-user
>  
>




More information about the User mailing list