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

Nick <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Basic Macro - Data sort     |Basic Macro - Data sort
                   |within a do loop stops      |does not sort mixed
                   |sorting after 2 loops       |positive and negative
                   |                            |numbers correctly

--- Comment #1 from Nick <[email protected]> ---
        x = 3
        b = 4
        q = 20
        y = x + (b - 1)
        k = 0

        Do Until k = q
        oSheet = ThisComponent.Sheets(5)
        sTextR = "A" & Trim(Str(x)) & ":I" & Trim(Str(y))
        oRange = oSheet.getCellRangeByName(sTextR)
        oSortFields(0).Field = 7
        oSortFields(0).SortAscending = FALSE
        oSortFields(1).FieldType = com.sun.star.util.SortFieldType.NUMERIC
        oSortDesc(0).Name = "SortFields"
        oSortDesc(0).Value = oSortFields()

        oRange.Sort(oSortDesc())
        x = x + 6
        y = x + (b - 1)
        k = k + 1

        Loop

The above code works perfectly if there are only poitive or negative numbers.
2       3       1NT     N       8       9 C     120
1       1       2♠      N       8       J D     110
3       5       2♦      S       8       K C     90
4       2       1♠      E       6       8 C     50

2       2       4♦      E       11      3 S     -150
3       4       3♠      W       11      8 D     -200
4       1       4♠      W       11      4 H     -450
1       5       4♠      E       11      3 D     -450

But if there are mixed oositive and negative numbers, the sort result are
incorrect.

4       2       2♣      N       7       J H     -50
2       3       2NT     N       7       4 C     -50
3       5       2NT     N       8       4 C     120
1       1       2♥      N       8       K S     110

This is what I expect, which I got manually with sort in the toolbar:
3       5       2NT     N       8       4 C     120     3
1       1       2♥      N       8       K S     110     2
4       2       2♣      N       7       J H     -50     0½
2       3       2NT     N       7       4 C     -50     0½

Another incorrect example:
4       2       2♦      E       9       2 H     -110
3       5       1♦      E       9       K H     -110
1       1       3♠      N       10      A H     170
2       3       2♦      E       10      2 C     -130

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to