Compare and sort have baffled me already...

BlitzMax Forums/BlitzMax Beginners Area/Compare and sort have baffled me already...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi,

Yep, TList.Remove uses Object.Compare, which is why you're getting weird results. In fact, the version you posted doesn't delete anything because Compare never returns 0! Should it behave like this or just use '='? I'm not sure yet, but this side of things does need some work.

Anyways, the best solution is probably to store the TLink returned by TList.AddLast, and use Remove() directly on that, eg:

Field link:TLink
.
.
.
link=globallist.AddLast( self ) 'add self to globallist
.
.
.
link.Remove 'remove self from globallist

This will be fastest, and allows you to keep using Compare for sorting if you want.