Sorting any field

BlitzMax Forums/BlitzMax Beginners Area/Sorting any field

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.

Type Bob
  Field X,Y
  Field SortUsingY

  Method Compare(other:Object)
    If Bob(other)
      If SortUsingY
        Return Sgn(Y - Bob(other).Y)
      Else
        Return Sgn(X - Bob(other).X)
      EndIf
    EndIf
    Return -1
  EndMethod
EndType
Or something like that. It's probably better to have a global variable controlling which parameter to use, instead of one for each type instance.