Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introducedin
09.1

Description

Excerpt

The sort method allows a user to sort an area by a particular column in the area. This method can sort numeric, alphabetic, and alphanumeric data. The user can also specify if the area contains headers, and whether to sort by ascending or descending.

Signature
C#
C#
 public static void Sort(Integer columnIndex, bool isAscending, bool hasHeader)
Signature
vb.net
vb.net
Public Static void Sub Sort(ByVal columnIndex As integer, ByVal isAscending As bool, ByVal hasHeader As bool)

Parameters

Param
0columnIndex

An integer representing the column you would like to sort the area by.

Param
0isAscending

A boolean representing whether you want to sort the area in ascending or descending order.

Param
0hasHeader

A booleanrepresenting whether or not the area you want to sort contains a header row.

Example
Code Block
csharp
csharp
titleC#
//Sort area with headers by the first column ascending 
Area a = WB[0].CreateArea("A1:C6");
a.Sort(0, true, true);
            
//Sort area with headers by first column descending
Area b = WB[0].CreateArea("A10:C15");
b.Sort(0, false, true);
            
//Sort area without headers by the first column ascending
Area c = WB[0].CreateArea("E2:G6");
c.Sort(0, true, false);
            
//Sort area without headers by the first column descending
Area d = WB[0].CreateArea("E11:G15");
d.Sort(0, false, false);
Code Block
vbnet
vbnet
titlevb.net
'Sort area with headers by the first column ascending 
Dim a As Area = WB(0).CreateArea("A1:C6")
a.Sort(0, True, True)


'Sort area with headers by first column descending
Dim b As Area = WB(0).CreateArea("A10:C15")
b.Sort(0, False, True)


'Sort area without headers by the first column ascending
Dim c As Area = WB(0).CreateArea("E2:G6")
c.Sort(0, True, False)


'Sort area without headers by the first column descending
Dim d As Area = WB(0).CreateArea("E11:G15")
d.Sort(0, False, False)