Enabling NaturalSort in Basic Macro?

asked 2019-08-29 13:55:21 +0100

Pez gravatar image

I've gotten nowhere trying to get this to work, sorting style Natural - is there a way to specify NaturalSort without resolving to record a macro and use?

The below function works, but sorts "11:5" before "7:0", by using NaturalSort it would sort "correctly".

Function SortList
        Dim sPK as Object
        sPK=ThisComponent.getSheets().getbyName("Result One")

    Range = sPK.getCellrangeByName("A6:E100")

    Dim SortFields(0) as New com.sun.star.table.TableSortField

    SortFields(0).Field = 4   'Column E = TIME
    SortFields(0).FieldType = "AlphaNumeric" 'Sort as text
    SortFields(0).IsAscending = "True"

    SortDesc = Range.createSortDescriptor
    SortDesc(3).Value = SortFields()

    Range.sort(SortDesc)
End Function

Original data is CSV text with this field being MM:SS so using text instead of converting seemed "natural" to me :)

edit retag flag offensive close merge delete