List sort ?

BlitzMax Forums/BlitzMax Programming/List sort ?

Filax(Posted 2005) [#1]
Hi :)

I'm trying to sort a list content but without result :



I have try to find method in the forum (search) but without succes...


Dreamora(Posted 2005) [#2]
You have to override the method compare (other:object) in your own type

it returns an int.

return 1 means other is > than self
return 0 means other is = to self
return -1 means other is < than self


Filax(Posted 2005) [#3]
Thanks dream, i'll try :)


Filax(Posted 2005) [#4]
I love you dream :) thanks for help :)

This is a good method to sort list value :




Grisu(Posted 2005) [#5]
Ahm Filax. Could you add list sorting to your gui?
So that user can sort lists upwards or downwards? :)


Filax(Posted 2005) [#6]
Good idea :)


Filax(Posted 2005) [#7]
I have try to make a sort method it work ! but the problem is what is
the good method to sort ! example :

I have a listbox with

NAME TITI
NAME TOTO
NAME TUTU
NAME TETE

What can i sort ?? with a listbox containing number's it's really
simple :) example :

10
200
30
400

but with text ? I'm thinking to analyze the first item letter but in the
previous example all item's have the same letter !

An idea ?


fredborg(Posted 2005) [#8]
Method Compare(p:Object)
pr:mytype= mytype(p)

Return self.text.Compare(pr.text)
End Method


Filax(Posted 2005) [#9]
Many thanks fredborg :) alway here to save me :)


Filax(Posted 2005) [#10]
It's ok :) now Iglass can sort listbox item's :)

MyList.SortItems()
'MyList.SortItems(False) ' ascending off


Grisu(Posted 2005) [#11]
I mostly have nice ideas, but cant solve them myself...

I should become creative manager! :D


Filax(Posted 2005) [#12]
Lol :)


wedoe(Posted 2006) [#13]
There's a lot of sortlist threads in the forums but
this one is the one that made me understand it !

Dreamora's explanation and filax simple code-example
is all it took ! Fredborgs string-addon is also good...

Thanks all and *bump* ;o)


Paposo(Posted 2006) [#14]
Hi guys.

Sorry for mi bad english.
In the thread Little Mod i publish any mod with any replacement for class TMap.
Is posible use it for sort any data. The data entered are automatically sorted. The problem arent the duplicates.

Other class contained are a queue with priority. It have duplicates. Problem are de keys. The keys only accept Integers.

The source is available and accept changes for your adaptation.

Get the mod, docs and source in:

ftp://www.furula.com/rvm.mod.zip

Bye,
Ramon


Foolish(Posted 2008) [#15]
For this to work for me I had to include the return type of int in the method call like so:

Method Compare:Int(p:Object)