Sorting an array of null objects

BlitzMax Forums/BlitzMax Programming/Sorting an array of null objects

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.

Not sure whether this should happen or not.

If you do:

Local a:Object[5]

Rem 
'uncomment this to solve it since they are no longer null
For Local i:Int = 0 To 4
	a[i] = New TImage
Next
EndRem

a.sort()



It causes an unhandled memory exception.

I realise this is because it's trying to access the compare method of the null object, but would it not be better to simply stop the sort there rather than throw an exception?

*EDIT*
for instance, the first two elements could contain a valid object, but the array can't be sorted until all elements are valid.