On Oct 2, 2006, at 4:48 PM, Karen wrote:

But meanwhile, SortWith is pretty handy and, apparently,
underappreciated.  :)

It's not hard to use for relatively simple sorts, but if the object array is large and involes 2 or 3 object fields, having to do a first pass to create the string array could be relatively costly, no?

Or would that likely not be significant because of the overhead of calling the Compare method each time in the sort?

Not that I have a ton of experience, but I think it would be about the same in terms of speed... or possibly even faster for the first method because the comparison values are cached into a standard (and optimized) sortable datatype.

The size of the array doesn't matter too much because it is always going to take longer to sort large arrays than it will small ones.

The bigger issue with the a Compare() approach that it will remain rather limited until REALbasic provides some method to inspect properties of generic objects. You could implement a ComparableInterface but how would you specify which property to sort by? In addition, you couldn't overload the return value, so you would really have to have at least three interfaces: CompareAsStringInterface, CompareAsIntegerInterface, and CompareAsDoubleInterface. But then you still wouldn't be able to specify which property to sort by if there were multiple options... for example a Person class might want to sort by FamilyName and by FirstName. But once REALbasic has object introspection (is that right?) then you could have a syntax something like:

    Dim theArray() As myClass

    theArray.SortBy(myClass.theProperty)

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to