On Sep 8, 2006, at 1:58 PM, Charles Yeomans wrote:

The main reason I want to know if is stable. I want to use it to sort multicolumn list using comparerows. Otherwise, I will have to adapt to my
needs the very good sort library of Charles Yeomans.

It should be pointed out that you can ensure a stable sort by supplying a suitable CompareRows Event Handler.


I'm not so sure about that -- stability is a function of the sorting algorithm itself, not the comparison.

You need to supply a CompareRows that generates a total ordering. It would use the ordering you otherwise want to use, then fall back on the row ordering if the original ordering comes out equal. Something roughly like this (assume we're comparing cell tags that support Operator_Compare):

Sub CompareRows(row1 As Integer, row2 As Integer, column As Integer) As Integer
        Dim Obj1 As Variant = Me.CellTag(row1, column)
        Dim Obj2 As Variant = Me.CellTag(row2, column)
        Dim result As Integer = Obj1.Operator_Compare(Obj2)
        If result = 0 Then result = row1 - row2
        Return result
End Sub

Guyren G Howe
Relevant Logic LLC

guyren-at-relevantlogic.com ~ http://relevantlogic.com

REALbasic, PHP, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training


_______________________________________________
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