Link Search Menu Expand Document

CSVDocument.Sort Method

Explanation Sort CSV data.

The sort order can be arbitrarily specified by character string for key specification.
Call format csvdoc.Sort( key1 [, key2 [, key3, … ] ] )
Return value None
Arguments String key Key specification string that specifies the sort order

Can specify at least one and as many as the number of columns at the maximum, and if want to specify more than one, the specified order will be prioritized.

Specify in the following format:-

    column [mode] [arrangement]
    
column Specify the column that will be the sort key with a column number starting from 0
mode mode Specify "n" when comparing the sort key as a numerical value (if omitted, comparison will be conducted in character string)
arrangement Specify "d" to sort in descending order (order in ascending if omitted)

Example:-
"0d" First column in descending order by string comparison
"3nd" 4th column in descending order by numerical comparison
"1" Second column in ascending order by string comparison
Exception None
Example of use
    var csvdoc = new CSVDocument;
    csvdoc << Form1.Spread1.row;
    csvdoc.Sort("0d", "3nd", "1");
    Form1.Spread1.row << csvdoc;
    
Related item