https://bugs.documentfoundation.org/show_bug.cgi?id=89803

            Bug ID: 89803
           Summary: BubbleSortList doesn't sorted correctly.
           Product: LibreOffice
           Version: unspecified
          Hardware: Other
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: [email protected]
          Reporter: [email protected]

Created attachment 113851
  --> https://bugs.documentfoundation.org/attachment.cgi?id=113851&action=edit
Macro of BubbleSortList_2

Dear Madam or Sir, 
First I would like apologize for my faulty English but I am learning yet. 
I hope you understand me even so.
In Libre-Office Macros/Tools/Strings exists the macro "BubbleSortList". 
I'm afraid isn't right the result of this macro. Words wich begins with little
letters and/or umlauts won't be sorting imprecisely.
Libre-Office sorted correct.
The reworked tool "BubblesortList_2" produces the same list like Libre-Office.
In accordance with the orthography regulations will handle umlauts like not
umlauted vowels.
This function BubbleSortList_2 sorts an array it's no matter how many fields.
The array will sort after the field wich number's as second parameters hand
over.
The default sorting order is the first dimension (sortfield is missing or
sortfield = 0)
Function BubbleSortList_2(ByVal SortList(), optional sortfield) 
'This function BubbleSortList_2 sorts an array it's no matter how many fields. 
'The array will sorted after the field with number of sortfield start by 0. 
'The default sorting order is the first dimension (sortfield is missing or
sortfield = 0) 
    Dim s As Integer 
    Dim t As Integer 
    Dim i As Integer 
    Dim k As Integer 
    Dim Field As Integer 
    Dim DisplayDummy 
    Dim Dummylist(0) As String 
    Dim Dummylist2(0,2) As String 
    Dim InitialASC As Integer 
    Dim Initialletter As String 
    Dim dimension As Integer 
'Test dimension 
    On Local Error GoTo ErrorDim 
    dimension = - 1 
    Do 
        dimension = dimension + 1 
        Initialletter = SortList(0,dimension) 
    Loop Until Err > 0 
    ErrorDim: 
    If Err = 9 Then 
        dimension = dimension - 1 
    Else 
        If Err = 6 Then 
            dimension = 1 
            sortfield = 0 
        End If 
    End If 
    If Ismissing(sortfield) Then 
        Field = 1 
    Else 
        If Isnumeric(sortfield) Then 
            If sortfield = 0 Then 
                Field = 0 
            Else 
                Field = sortfield 
            End If 
        Else 
        'On account of compatibility to original BubbleSortList 
        'That is to say if sortfield = true 
            If LCase(Sortfield) = "true" then 
                Field = 1 
            Else 
                Field = 0 
            End If 
        End If 
    End If 
    If Field > dimension And dimension > 0 Then 
        Msgbox(Error(9)) 
        Stop 
    End If 
    ReDim Dummylist(UBound(SortList())) As String 
    If dimension < 2 Then 
        ReDim DummyList2(UBound(SortList()),2) As String 
    Else 
        ReDim DummyList2(UBound(SortList()),dimension+1) As String 
    End If 
'The information which requisite to sort will broadcast in this loop 
    For i = 0 To UBound(SortList()) 
        If dimension = 0 Then 
            Dummylist2(i,1) = SortList(i) 
        Else 
            If SortList(i,Field) = "" Then 
                Dummylist2(i,1) = "zzz" & SortList(i,Field-1) 
            Else 
                Dummylist2(i,1) = SortList(i,Field) 
            End If 
        End If 
    'Data set number 
        DummyList2(i,2) = i 
    Next 
'From here will only use array Dummylist2 
    For i = 0 To UBound(Dummylist2()) 
        Initialletter = Dummylist2(i,1) 
        If Initialletter <> "" Then 
            InitialASC = ASC(Mid(Dummylist2(i,1),1,1)) 
        'Initialletter exchange and with the rest put together 
            Select Case InitialASC 
                Case 192 To 198, 224 To 230    'À, Á, Ã, Ä, Å, Æ, à, á, â, ã,
ä, å, æ
                Initialletter = "a" 
                Case 199, 231    'Ç, ç
                Initialletter = "c" 
                Case 200 To 203, 232 To 235    'È, É, Ê, Ë, è, é, ê, ë
                Initialletter = "e" 
                Case 204 To 207, 236 To 239    'Ì, Í, Î, Ï, ì, í, î, ï
                Initialletter = "i" 
                Case 208, 240    'Ð
                Initialletter = "d" 
                Case 209 , 241    'Ñ
                Initialletter = "n" 
                Case 210 To 214, 242 To 246    'Ò, Ó, Ô, Õ, Ö, ö, ò, ó, ô, õ, ö
                Initialletter = "o" 
                Case 217 To 220, 249 To 252    'Ù, Ú, Û, Ü, ù, ú, û, ü 
                Initialletter = "u" 
                Case 221, 253    'Ý, ý
                Initialletter = "y" 
                Case Else 
                Initialletter = LCase(Mid(Dummylist2(i,1),1,1)) 
            End Select 
        Else 
            Initialletter = "zzz" & Dummylist2(i,1) 
        End If 
        Initialletter = Initialletter &
Mid(Dummylist2(i,1),2,len(Dummylist2(i,1)) 
        Dummylist2(i,0) = Initialletter 
    Next 
    i = UBound(Dummylist2()) 
    For s = 1 To i - 1 
        For t = 0 To i-s 
            If Dummylist2(t,0) > Dummylist2(t+1,0) Then 
                For k = 0 To dimension+1 
                    DisplayDummy = Dummylist2(t,k) 
                    Dummylist2(t,k) = Dummylist2(t+1,k) 
                    Dummylist2(t+1,k) = DisplayDummy 
                Next k 
            End If 
        Next t 
    Next s 
    If dimension > 0 Then 
        Dim SetNr As Integer 
        For i = 0 To UBound(Dummylist2()) 
            SetNr = Dummylist2(i,2) 
            For s = 0 To dimension 
                Dummylist2(i,s) = SortList(SetNr,s) 
            Next 
        Next 
    End If 
    If dimension = 0 Then 
        For i = 0 To UBound(Dummylist2()) 
            Dummylist(i) = Dummylist2(i,1) 
        Next 
        BubbleSortList_2 = Dummylist() 
    Else 
        BubbleSortList_2 = Dummylist2() 
    End If 
End Function

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to