https://issues.apache.org/ooo/show_bug.cgi?id=125306
Issue ID: 125306
Issue Type: DEFECT
Summary: Sorting not stable from Basic macro
Product: Calc
Version: 4.0.1
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: programming
Assignee: [email protected]
Reporter: [email protected]
Created attachment 83738
--> https://issues.apache.org/ooo/attachment.cgi?id=83738&action=edit
test csv
When sorting from a Basic macro using the following function:
Function sort(col As Integer, doc As Object) As Long
Dim aSortFields(2) As New com.sun.star.util.SortField
Dim aSortDesc(0) As New com.sun.star.beans.PropertyValue
Dim count As Long
Dim cell As Object
Dim oSortRange As Object
Sheet = doc.Sheets.GetByName("Sheet1")
curs = Sheet.createCursor
curs.gotoEndOfUsedArea(True)
count = curs.Rows.Count
oSortRange = Sheet.getCellRangeByPosition(0,0,20,count)
aSortFields(0).Field = col
aSortFields(0).SortAscending = TRUE
aSortDesc(0).Name = "SortFields"
aSortDesc(0).Value = aSortFields()
oSortRange.Sort(aSortDesc())
sort() = count
end Function
the sort is not stable if the column you are sorting is not column 0.
Attched is a test csv file with 3 columns. There are 4 rows with a value of
"00037CMK3" in column B. The respective values in column C are in the order:
20140402
20140403
20140407
20140409
After sorting by column B, the order of column C becomes:
20140407
20140402
20140403
20140409
--
You are receiving this mail because:
You are the assignee for the issue.
You are watching all issue changes.