Syntax 1: Sorts the specified table column.
Syntax 2: Sorts the specified table.
Syntax 3: Sorts the paragraphs in the specified range or selection.
Syntax 1
expression.Sort(ExcludeHeader, SortFieldType, SortOrder, CaseSensitive, BidiSort, IgnoreThe, IgnoreKashida, IgnoreDiacritics, IgnoreHe, LanguageID)
Syntax 2
expression.Sort(ExcludeHeader, FieldNumber, SortFieldType, SortOrder, FieldNumber2, SortFieldType2, SortOrder2, FieldNumber3, SortFieldType3, SortOrder3, CaseSensitive, BidiSort, IgnoreThe, IgnoreKashida, IgnoreDiacritics, IgnoreHe, LanguageID)
Syntax 3
expression.Sort(ExcludeHeader, FieldNumber, SortFieldType, SortOrder, FieldNumber2, SortFieldType2, SortOrder2, FieldNumber3, SortFieldType3, SortOrder3, SortColumn, Separator, CaseSensitive, BidiSort, IgnoreThe, IgnoreKashida, IgnoreDiacritics, IgnoreHe, LanguageID)
expression Syntax 1: Required. An expression that returns a Column object.
Syntax 2: Required. An expression that returns a Table object.
Syntax 3: Required. An expression that returns a Range or Selection object.
ExcludeHeader Optional Variant. True to exclude the first row or paragraph from the sort operation. The default value is False.
FieldNumber, FieldNumber2, FieldNumber3 Optional Variant. The fields to sort by. Microsoft Word sorts by FieldNumber, then by FieldNumber2, and then by FieldNumber3.
SortFieldType, SortFieldType2, SortFieldType3 Optional Variant. The column sort type (Syntax 1) or the respective sort types for FieldNumber, FieldNumber2, and FieldNumber3 (Syntax 2 and Syntax 3). Can be one of the following WdSortFieldType constants: wdSortFieldAlphanumeric, wdSortFieldDate, wdSortFieldJapanJIS, wdSortFieldKoreaKS, wdSortFieldNumeric, wdSortFieldStroke, or wdSortFieldSyllable. The default value is wdSortFieldAlphanumeric. Some of these constants may not be available to you, depending on the language support (U.S. English, for example) that you’ve selected or installed.
SortOrder, SortOrder2, SortOrder3 Optional Variant. The column sorting order (Syntax 1) or the sorting order to use when sorting FieldNumber, FieldNumber2, and FieldNumber3 (Syntax 2 and Syntax 3). Can be one of the following WdSortOrder constants: wdSortOrderAscending or wdSortOrderDescending. The default value is wdSortAscending.
SortColumn Optional Variant. True to sort only the column specified by the Range or Selection object.
Separator Optional Variant. The type of field separator. Can be one of the following WdSortSeparator constants: wdSortSeparateByCommas, wdSortSeparateByDefaultTableSeparator, or wdSortSeparateByTabs. The default value is wdSortSeparateByCommas. If the range or selection is in a table, this argument is ignored.
CaseSensitive Optional Variant. True to sort with case sensitivity. The default value is False.
BidiSort Optional Variant. True to sort based on right-to-left language rules. This argument may not be available to you, depending on the language support (U.S. English, for example) that you’ve selected or installed.
IgnoreThe Optional Variant. True to ignore the Arabic character "Alef Lam" when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you’ve selected or installed.
IgnoreKashida Optional Variant. True to ignore kashidas when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you’ve selected or installed.
IgnoreDiacritics Optional Variant. True to ignore bidirectional control characters when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you’ve selected or installed.
IgnoreHe Optional Variant. True to ignore the Hebrew character "He" when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you’ve selected or installed.
LanguageID Optional Variant. Specifies the sorting language. Can be one of the WdLanguageID constants.
Remarks
If you want to sort paragraphs within a table cell, include only the paragraphs and not the end-of-cell mark; if you include the end-of-cell mark in a selection or range and then attempt to sort the paragraphs, Word displays a message stating that it found no valid records to sort.