Sort Data Table by first digit

Hello, I am using a Application. It sorts number like that
The image displays a table column labeled "Operator Voucher" with a list of numerical values. (Captioned by AI)
normally 11087192 > 15303 but for App 11087192 < 15303. I think it compare digit to digit. How can I do that

Hie @Murat so you want to sort this data table in Ascending Form Right ??

Yes, I sort table Ascending but It is inconsistent with what App is doing

@Murat so you can do one thing first save that web data after this you can use the sort table activity to sort your table data …

Hi @Murat

Try this

dtSorted = dtInput.AsEnumerable().
    OrderBy(Function(row) row("Operator Voucher").ToString(), StringComparer.Ordinal).
    CopyToDataTable()

Regards,

1 Like

@Murat,

I havn’t tested it but try this.

sortedDataTable = (From row In YourDataTableVariable.AsEnumerable()
                   Order By row("Operator Voucher").ToString.Length, row("Operator Voucher").ToString
                   Select row).CopyToDataTable()

Thanks,
Ashok :slight_smile:

we cannot control the app (looks like it is sorting lexically).

But we can read in the datatable e.g. with table extraction and sort it by
Assign Activity:
dtSorted | DataType: DataTable =

(From d in ExtractedData.AsEnumerable
Let vi = CInt(d("Operator Voucher").toString.Trim)
Order by vi
Select r = d).CopyToDataTable

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.